Use console.Debugln instead of log.Debug.Println
This commit is contained in:
+6
-7
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
func runAccessCmd(ctx *cli.Context) {
|
||||
@@ -36,7 +35,7 @@ func runAccessCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("loading config file failed with following reason: [%s]\n", iodine.ToError(err))
|
||||
}
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
@@ -44,23 +43,23 @@ func runAccessCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("reading URL [%s] failed with following reason: [%s]\n", e.url, e)
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("reading URLs failed with following reason: [%s]\n", e)
|
||||
}
|
||||
}
|
||||
acl := bucketACL(ctx.Args().First())
|
||||
if !acl.isValidBucketACL() {
|
||||
log.Debug.Println(iodine.New(errInvalidACL{acl: acl.String()}, nil))
|
||||
console.Debugln(iodine.New(errInvalidACL{acl: acl.String()}, nil))
|
||||
console.Fatalf("Access type [%s] is not supported. Valid types are [private, public, readonly].\n", acl)
|
||||
}
|
||||
targetURLs = targetURLs[1:] // 1 or more target URLs
|
||||
for _, targetURL := range targetURLs {
|
||||
targetConfig, err := getHostConfig(targetURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read configuration for host [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
||||
}
|
||||
targetURLConfigMap[targetURL] = targetConfig
|
||||
@@ -72,7 +71,7 @@ func runAccessCmd(ctx *cli.Context) {
|
||||
if errorMsg == "" {
|
||||
errorMsg = "Empty error message. Please rerun this command with --debug and file a bug report."
|
||||
}
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Errorf("%s", errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
func runCatCmd(ctx *cli.Context) {
|
||||
@@ -38,7 +37,7 @@ func runCatCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("loading config file failed with following reason: [%s]\n", iodine.ToError(err))
|
||||
}
|
||||
|
||||
@@ -47,10 +46,10 @@ func runCatCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("reading URL [%s] failed with following reason: [%s]\n", e.url, e)
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("reading URLs failed with following reason: [%s]\n", e)
|
||||
}
|
||||
}
|
||||
@@ -58,12 +57,12 @@ func runCatCmd(ctx *cli.Context) {
|
||||
sourceURLs := urls
|
||||
sourceURLConfigMap, err := getHostConfigs(sourceURLs)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("reading host config for URL [%s] failed with following reason: [%s]\n", sourceURLs, iodine.ToError(err))
|
||||
}
|
||||
humanReadable, err := doCatCmd(sourceURLConfigMap, globalDebugFlag)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalln(humanReadable)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/mc/pkg/quick"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
// runConfigCmd is the handle for "mc config" sub-command
|
||||
@@ -35,12 +34,12 @@ func runConfigCmd(ctx *cli.Context) {
|
||||
arg := ctx.Args().First()
|
||||
tailArgs := ctx.Args().Tail()
|
||||
if len(tailArgs) > 2 {
|
||||
log.Debug.Println(iodine.New(errInvalidArgument{}, nil))
|
||||
console.Debugln(iodine.New(errInvalidArgument{}, nil))
|
||||
console.Fatalln("Incorrect number of arguments, please use \"mc config help\"")
|
||||
}
|
||||
msg, err := doConfig(arg, tailArgs)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalln(msg)
|
||||
}
|
||||
console.Infoln(msg)
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
func runCopyCmd(ctx *cli.Context) {
|
||||
@@ -34,7 +33,7 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read config file [%s]. Reason: [%s].\n", mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
|
||||
@@ -43,10 +42,10 @@ func runCopyCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unknown type of URL(s).\n")
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to parse arguments. Reason: [%s].\n", e)
|
||||
}
|
||||
}
|
||||
@@ -64,7 +63,7 @@ func runCopyCmdMultipleSources(urls []string) {
|
||||
targetURL := urls[len(urls)-1] // Last one is target
|
||||
targetConfig, err := getHostConfig(targetURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n",
|
||||
targetURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
@@ -83,26 +82,26 @@ func runCopyCmdMultipleSources(urls []string) {
|
||||
for _, newRecursiveSourceURL := range newRecursiveSourceURLs {
|
||||
newRecursiveSourceConfig, err := getHostConfig(newRecursiveSourceURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the source %s from config file [%s]. Reason: [%s].\n",
|
||||
newRecursiveSourceURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
err = doCopySingleSourceRecursive(newRecursiveSourceURL, targetURL, newRecursiveSourceConfig, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to copy from source %s to target %s. Reason: [%s].\n", newRecursiveSourceURL,
|
||||
targetURL, iodine.ToError(err))
|
||||
}
|
||||
}
|
||||
newRegularSourceURLConfigMap, err := getHostConfigs(newRegularSourceURLs)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following sources [%s] from config file [%s]. Reason: [%s].\n",
|
||||
newRegularSourceURLs, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
err = doCopyMultipleSources(newRegularSourceURLConfigMap, targetURL, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to copy from following sources [%s] to target %s. Reason: [%s].\n",
|
||||
newRegularSourceURLs, targetURL, iodine.ToError(err))
|
||||
}
|
||||
@@ -114,7 +113,7 @@ func runCopyCmdSingleSource(urls []string) {
|
||||
targetURL := urls[1]
|
||||
targetConfig, err := getHostConfig(targetURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n",
|
||||
targetURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
@@ -125,21 +124,21 @@ func runCopyCmdSingleSource(urls []string) {
|
||||
}
|
||||
sourceConfig, err := getHostConfig(sourceURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n",
|
||||
sourceURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
if recursive {
|
||||
err = doCopySingleSourceRecursive(sourceURL, targetURL, sourceConfig, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n", sourceURL, targetURL, iodine.ToError(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
err = doCopySingleSource(sourceURL, targetURL, sourceConfig, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n", sourceURL, targetURL, iodine.ToError(err))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
// runListCmd - is a handler for mc ls command
|
||||
@@ -37,7 +36,7 @@ func runListCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read config file [%s]. Reason: [%s].\n", mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
@@ -46,16 +45,16 @@ func runListCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unknown type of URL [%s].\n", arg)
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to parse argument [%s]. Reason: [%s].\n", arg, iodine.ToError(err))
|
||||
}
|
||||
}
|
||||
targetConfig, err := getHostConfig(targetURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for [%s] from config file [%s]. Reason: [%s].\n",
|
||||
targetURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
@@ -68,14 +67,14 @@ func runListCmd(ctx *cli.Context) {
|
||||
err = doListRecursiveCmd(targetURL, targetConfig, globalDebugFlag)
|
||||
err = iodine.New(err, nil)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to list [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
||||
}
|
||||
} else {
|
||||
err = doListCmd(targetURL, targetConfig, globalDebugFlag)
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to list [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/minio-io/mc/pkg/client"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
// runMakeBucketCmd is the handler for mc mb command
|
||||
@@ -37,7 +36,7 @@ func runMakeBucketCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read config file [%s].\n", mustGetMcConfigPath())
|
||||
}
|
||||
targetURLConfigMap := make(map[string]*hostConfig)
|
||||
@@ -45,17 +44,17 @@ func runMakeBucketCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unknown URL type [%s] passed. Reason: [%s].\n", e.url, e)
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Error in parsing path or URL. Reason: [%s].\n", e)
|
||||
}
|
||||
}
|
||||
for _, targetURL := range targetURLs {
|
||||
targetConfig, err := getHostConfig(targetURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read configuration for host [%s]. Reason: [%s].\n", targetURL, iodine.ToError(err))
|
||||
}
|
||||
targetURLConfigMap[targetURL] = targetConfig
|
||||
@@ -67,7 +66,7 @@ func runMakeBucketCmd(ctx *cli.Context) {
|
||||
if errorMsg == "" {
|
||||
errorMsg = "Empty error message. Please rerun this command with --debug and file a bug report."
|
||||
}
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Errorf("%s", errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-7
@@ -22,7 +22,6 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
func runSyncCmd(ctx *cli.Context) {
|
||||
@@ -34,7 +33,7 @@ func runSyncCmd(ctx *cli.Context) {
|
||||
}
|
||||
config, err := getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read config file [%s]. Reason: [%s].\n", mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
|
||||
@@ -43,10 +42,10 @@ func runSyncCmd(ctx *cli.Context) {
|
||||
if err != nil {
|
||||
switch e := iodine.ToError(err).(type) {
|
||||
case errUnsupportedScheme:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unknown type of URL(s).\n")
|
||||
default:
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to parse arguments. Reason: [%s].\n", e)
|
||||
}
|
||||
}
|
||||
@@ -64,13 +63,13 @@ func runCopyCmdSingleSourceMultipleTargets(urls []string) {
|
||||
}
|
||||
sourceConfig, err := getHostConfig(sourceURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the source %s from config file [%s]. Reason: [%s].\n",
|
||||
sourceURL, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
targetURLConfigMap, err := getHostConfigs(targetURLs)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read host configuration for the following targets [%s] from config file [%s]. Reason: [%s].\n",
|
||||
targetURLs, mustGetMcConfigPath(), iodine.ToError(err))
|
||||
}
|
||||
@@ -78,7 +77,7 @@ func runCopyCmdSingleSourceMultipleTargets(urls []string) {
|
||||
for targetURL, targetConfig := range targetURLConfigMap {
|
||||
err = doCopySingleSourceRecursive(sourceURL, targetURL, sourceConfig, targetConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(err)
|
||||
console.Debugln(err)
|
||||
console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n",
|
||||
sourceURL, targetURL, iodine.ToError(err))
|
||||
}
|
||||
|
||||
+2
-3
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -60,14 +59,14 @@ func runUpdateCmd(ctx *cli.Context) {
|
||||
}
|
||||
hostConfig, err := getHostConfig(mcUpdateURL)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read configuration for host [%s]. Reason: [%s].\n", mcUpdateURL, iodine.ToError(err))
|
||||
}
|
||||
switch ctx.Args().First() {
|
||||
case "check":
|
||||
msg, err := doUpdateCheck(hostConfig)
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf(msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/user"
|
||||
"runtime"
|
||||
@@ -29,14 +28,13 @@ import (
|
||||
"github.com/minio-io/cli"
|
||||
"github.com/minio-io/mc/pkg/console"
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
"github.com/minio-io/minio/pkg/utils/log"
|
||||
)
|
||||
|
||||
// Check for the environment early on and gracefully report.
|
||||
func checkConfig() {
|
||||
_, err := user.Current()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalln("Unable to determine current user")
|
||||
}
|
||||
|
||||
@@ -48,7 +46,7 @@ func checkConfig() {
|
||||
// Ensures config file is sane
|
||||
_, err = getMcConfig()
|
||||
if err != nil {
|
||||
log.Debug.Println(iodine.New(err, nil))
|
||||
console.Debugln(iodine.New(err, nil))
|
||||
console.Fatalf("Unable to read config file: %s\n", mustGetMcConfigPath())
|
||||
}
|
||||
}
|
||||
@@ -108,8 +106,7 @@ func main() {
|
||||
globalMaxRetryFlag = ctx.GlobalInt("retry")
|
||||
if globalDebugFlag {
|
||||
app.ExtraInfo = getSystemData()
|
||||
} else {
|
||||
log.Debug = log.New(ioutil.Discard, "", 0)
|
||||
console.NoDebugPrint = false
|
||||
}
|
||||
themeName := ctx.GlobalString("theme")
|
||||
if console.IsValidTheme(themeName) {
|
||||
|
||||
+39
-11
@@ -28,6 +28,9 @@ import (
|
||||
"github.com/minio-io/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// NoDebugPrint defines if the input should be printed or not. By default it's set to true.
|
||||
var NoDebugPrint bool = true
|
||||
|
||||
var (
|
||||
mutex = &sync.RWMutex{}
|
||||
|
||||
@@ -66,11 +69,23 @@ var (
|
||||
Infof = func(f string, a ...interface{}) { printf(themesDB[currThemeName].Info, f, a...) }
|
||||
|
||||
// Debug prints a debug message
|
||||
Debug = func(a ...interface{}) { print(themesDB[currThemeName].Debug, a...) }
|
||||
Debug = func(a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
print(themesDB[currThemeName].Debug, a...)
|
||||
}
|
||||
}
|
||||
// Debugln prints a debug message with a new line
|
||||
Debugln = func(a ...interface{}) { println(themesDB[currThemeName].Debug, a...) }
|
||||
Debugln = func(a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
println(themesDB[currThemeName].Debug, a...)
|
||||
}
|
||||
}
|
||||
// Debugf prints a debug message with formatting
|
||||
Debugf = func(f string, a ...interface{}) { printf(themesDB[currThemeName].Debug, f, a...) }
|
||||
Debugf = func(f string, a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
printf(themesDB[currThemeName].Debug, f, a...)
|
||||
}
|
||||
}
|
||||
|
||||
// File - File("foo.txt")
|
||||
File = themesDB[currThemeName].File.SprintfFunc()
|
||||
@@ -214,17 +229,18 @@ func SetTheme(themeName string) error {
|
||||
|
||||
mutex.Lock()
|
||||
|
||||
currThemeName = themeName
|
||||
theme := themesDB[currThemeName]
|
||||
|
||||
// Just another additional precaution to completely disable color.
|
||||
// Color theme is also necessary, because it does other useful things like exit-on-fatal..
|
||||
if currThemeName == "nocolor" {
|
||||
switch currThemeName {
|
||||
case "nocolor":
|
||||
color.NoColor = true
|
||||
} else {
|
||||
default:
|
||||
color.NoColor = false
|
||||
}
|
||||
|
||||
currThemeName = themeName
|
||||
theme := themesDB[currThemeName]
|
||||
|
||||
// Error prints a error message
|
||||
Error = func(a ...interface{}) { print(theme.Error, a...) }
|
||||
// Errorln prints a error message with a new line
|
||||
@@ -240,11 +256,23 @@ func SetTheme(themeName string) error {
|
||||
Infof = func(f string, a ...interface{}) { printf(theme.Info, f, a...) }
|
||||
|
||||
// Debug prints a debug message
|
||||
Debug = func(a ...interface{}) { print(theme.Debug, a...) }
|
||||
Debug = func(a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
print(theme.Debug, a...)
|
||||
}
|
||||
}
|
||||
// Debugln prints a debug message with a new line
|
||||
Debugln = func(a ...interface{}) { println(theme.Debug, a...) }
|
||||
Debugln = func(a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
println(theme.Debug, a...)
|
||||
}
|
||||
}
|
||||
// Debugf prints a debug message with formatting
|
||||
Debugf = func(f string, a ...interface{}) { printf(theme.Debug, f, a...) }
|
||||
Debugf = func(f string, a ...interface{}) {
|
||||
if !NoDebugPrint {
|
||||
printf(theme.Debug, f, a...)
|
||||
}
|
||||
}
|
||||
|
||||
Dir = theme.Dir.SprintfFunc()
|
||||
File = theme.File.SprintfFunc()
|
||||
|
||||
Reference in New Issue
Block a user