diff --git a/cmd/background-newdisks-heal-ops.go b/cmd/background-newdisks-heal-ops.go index 22bf7b81a..1f74d245e 100644 --- a/cmd/background-newdisks-heal-ops.go +++ b/cmd/background-newdisks-heal-ops.go @@ -263,7 +263,7 @@ func initAutoHeal(ctx context.Context, objAPI ObjectLayer) { globalBackgroundHealState.pushHealLocalDisks(getLocalDisksToHeal()...) if drivesToHeal := globalBackgroundHealState.healDriveCount(); drivesToHeal > 0 { - logger.Info(fmt.Sprintf("Found drives to heal %d, waiting until %s to heal the content...", + logger.Info(fmt.Sprintf("Found drives to heal %d, waiting until %s to heal the content - use 'mc admin heal alias/ --verbose' to check the status", drivesToHeal, defaultMonitorNewDiskInterval)) // Heal any disk format and metadata early, if possible. @@ -333,7 +333,7 @@ func monitorLocalDisksAndHeal(ctx context.Context, z *erasureServerPools, bgSeq // Ensure that reformatting disks is finished bgSeq.queueHealTask(healSource{bucket: nopHeal}, madmin.HealItemMetadata) - logger.Info(fmt.Sprintf("Found drives to heal %d, proceeding to heal content...", + logger.Info(fmt.Sprintf("Found drives to heal %d, proceeding to heal - 'mc admin heal alias/ --verbose' to check the status.", len(healDisks))) erasureSetInPoolDisksToHeal = make([]map[int][]StorageAPI, len(z.serverPools)) @@ -404,13 +404,15 @@ func monitorLocalDisksAndHeal(ctx context.Context, z *erasureServerPools, bgSeq go func(setIndex int, disks []StorageAPI) { defer wg.Done() for _, disk := range disks { - logger.Info("Healing disk '%v' on %s pool", disk, humanize.Ordinal(i+1)) + if serverDebugLog { + logger.Info("Healing disk '%v' on %s pool", disk, humanize.Ordinal(i+1)) + } // So someone changed the drives underneath, healing tracker missing. tracker, err := loadHealingTracker(ctx, disk) if err != nil { - logger.Info("Healing tracker missing on '%s', disk was swapped again on %s pool", - disk, humanize.Ordinal(i+1)) + logger.LogIf(ctx, fmt.Errorf("Healing tracker missing on '%s', disk was swapped again on %s pool: %w", + disk, humanize.Ordinal(i+1), err)) tracker = newHealingTracker(disk) } @@ -438,12 +440,14 @@ func monitorLocalDisksAndHeal(ctx context.Context, z *erasureServerPools, bgSeq continue } - logger.Info("Healing disk '%s' on %s pool, %s set complete", disk, - humanize.Ordinal(i+1), humanize.Ordinal(setIndex+1)) - logger.Info("Summary:\n") - tracker.printTo(os.Stdout) + if serverDebugLog { + logger.Info("Healing disk '%s' on %s pool, %s set complete", disk, + humanize.Ordinal(i+1), humanize.Ordinal(setIndex+1)) + logger.Info("Summary:\n") + tracker.printTo(os.Stdout) + logger.Info("\n") + } logger.LogIf(ctx, tracker.delete(ctx)) - logger.Info("\n") // Only upon success pop the healed disk. globalBackgroundHealState.popHealLocalDisks(disk.Endpoint()) diff --git a/cmd/bootstrap-peer-server.go b/cmd/bootstrap-peer-server.go index 83eb09db8..e0e1dd90f 100644 --- a/cmd/bootstrap-peer-server.go +++ b/cmd/bootstrap-peer-server.go @@ -206,7 +206,7 @@ func verifyServerSystemConfig(ctx context.Context, endpointServerPools EndpointS for _, clnt := range clnts { if err := clnt.Verify(ctx, srcCfg); err != nil { if !isNetworkError(err) { - logger.Info(fmt.Errorf("%s has incorrect configuration: %w", clnt.String(), err).Error()) + logger.LogIf(ctx, fmt.Errorf("%s has incorrect configuration: %w", clnt.String(), err)) } offlineEndpoints = append(offlineEndpoints, clnt.String()) continue diff --git a/cmd/common-main.go b/cmd/common-main.go index ab1f5215d..c6828f95b 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -327,7 +327,7 @@ func checkUpdate(mode string) { return } - logStartupMessage(prepareUpdateMessage("\nRun `mc admin update`", lrTime.Sub(crTime))) + logger.Info(prepareUpdateMessage("Run `mc admin update`", lrTime.Sub(crTime))) } func newConfigDirFromCtx(ctx *cli.Context, option string, getDefaultDir func() string) (*ConfigDir, bool) { @@ -762,7 +762,7 @@ func handleCommonEnvVars() { " Please use %s and %s", config.EnvAccessKey, config.EnvSecretKey, config.EnvRootUser, config.EnvRootPassword) - logStartupMessage(color.RedBold(msg)) + logger.Info(color.RedBold(msg)) } globalActiveCred = cred } @@ -827,13 +827,6 @@ func handleCommonEnvVars() { } } -func logStartupMessage(msg string) { - if globalConsoleSys != nil { - globalConsoleSys.Send(msg, string(logger.All)) - } - logger.StartupMessage(msg) -} - func getTLSConfig() (x509Certs []*x509.Certificate, manager *certs.Manager, secureConn bool, err error) { if !(isFile(getPublicCertFile()) && isFile(getPrivateKeyFile())) { return nil, nil, false, nil diff --git a/cmd/config-current.go b/cmd/config-current.go index 3e8e922bf..f3f2c677b 100644 --- a/cmd/config-current.go +++ b/cmd/config-current.go @@ -529,7 +529,7 @@ func lookupConfigs(s config.Config, objAPI ObjectLayer) { } if globalSTSTLSConfig.InsecureSkipVerify { - logger.Info("CRITICAL: enabling %s is not recommended in a production environment", xtls.EnvIdentityTLSSkipVerify) + logger.LogIf(ctx, fmt.Errorf("CRITICAL: enabling %s is not recommended in a production environment", xtls.EnvIdentityTLSSkipVerify)) } globalOpenIDConfig, err = openid.LookupConfig(s[config.IdentityOpenIDSubSys][config.Default], diff --git a/cmd/config-encrypted.go b/cmd/config-encrypted.go index 0fdd13133..ec8ee0fd3 100644 --- a/cmd/config-encrypted.go +++ b/cmd/config-encrypted.go @@ -74,7 +74,7 @@ func migrateIAMConfigsEtcdToEncrypted(ctx context.Context, client *etcd.Client) if err != nil { return err } - logger.Info("Attempting to re-encrypt IAM users and policies on etcd with %q (%s)", stat.DefaultKey, stat.Name) + logger.Info(fmt.Sprintf("Attempting to re-encrypt IAM users and policies on etcd with %q (%s)", stat.DefaultKey, stat.Name)) } listCtx, cancel := context.WithTimeout(ctx, 1*time.Minute) @@ -143,7 +143,7 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, encrypted bool) error { if err != nil { return err } - logger.Info("Attempting to re-encrypt config, IAM users and policies on MinIO with %q (%s)", stat.DefaultKey, stat.Name) + logger.Info(fmt.Sprintf("Attempting to re-encrypt config, IAM users and policies on MinIO with %q (%s)", stat.DefaultKey, stat.Name)) } var marker string diff --git a/cmd/disk-cache-backend.go b/cmd/disk-cache-backend.go index 7cdba615a..8d38a3d6f 100644 --- a/cmd/disk-cache-backend.go +++ b/cmd/disk-cache-backend.go @@ -24,6 +24,7 @@ import ( "crypto/rand" "encoding/base64" "encoding/hex" + "errors" "fmt" "io" "io/ioutil" @@ -252,16 +253,17 @@ func (c *diskCache) diskUsageLow() bool { // Returns if the disk usage reaches or exceeds configured cache quota when size is added. // If current usage without size exceeds high watermark a GC is automatically queued. func (c *diskCache) diskSpaceAvailable(size int64) bool { + reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir) + ctx := logger.SetReqInfo(GlobalContext, reqInfo) + gcTriggerPct := c.quotaPct * c.highWatermark / 100 di, err := disk.GetInfo(c.dir) if err != nil { - reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir) - ctx := logger.SetReqInfo(GlobalContext, reqInfo) logger.LogIf(ctx, err) return false } if di.Total == 0 { - logger.Info("diskCache: Received 0 total disk size") + logger.LogIf(ctx, errors.New("diskCache: Received 0 total disk size")) return false } usedPercent := float64(di.Used) * 100 / float64(di.Total) diff --git a/cmd/disk-cache.go b/cmd/disk-cache.go index 80f5a8890..90ffed4db 100644 --- a/cmd/disk-cache.go +++ b/cmd/disk-cache.go @@ -614,7 +614,7 @@ func newCache(config cache.Config) ([]*diskCache, bool, error) { } func (c *cacheObjects) migrateCacheFromV1toV2(ctx context.Context) { - logStartupMessage(color.Blue("Cache migration initiated ....")) + logger.Info(color.Blue("Cache migration initiated ....")) g := errgroup.WithNErrs(len(c.cache)) for index, dc := range c.cache { @@ -643,7 +643,7 @@ func (c *cacheObjects) migrateCacheFromV1toV2(ctx context.Context) { // update migration status c.migrating = false - logStartupMessage(color.Blue("Cache migration completed successfully.")) + logger.Info(color.Blue("Cache migration completed successfully.")) } // PutObject - caches the uploaded object for single Put operations diff --git a/cmd/erasure-object.go b/cmd/erasure-object.go index 522ed5660..71fb01f21 100644 --- a/cmd/erasure-object.go +++ b/cmd/erasure-object.go @@ -343,10 +343,8 @@ func (er erasureObjects) getObjectWithFileInfo(ctx context.Context, bucket, obje switch { case errors.Is(err, errFileNotFound): scan = madmin.HealNormalScan - logger.Info("Healing required, triggering async heal missing shards for %s", pathJoin(bucket, object, fi.VersionID)) case errors.Is(err, errFileCorrupt): scan = madmin.HealDeepScan - logger.Info("Healing required, triggering async heal bitrot for %s", pathJoin(bucket, object, fi.VersionID)) } switch scan { case madmin.HealNormalScan, madmin.HealDeepScan: diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index b1c1424fc..9566c1b76 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -221,7 +221,6 @@ func (s *erasureSets) connectDisks() { if err != nil { if endpoint.IsLocal && errors.Is(err, errUnformattedDisk) { globalBackgroundHealState.pushHealLocalDisks(endpoint) - logger.Info(fmt.Sprintf("Found unformatted drive %s, attempting to heal...", endpoint)) } else { printEndpointError(endpoint, err, true) } @@ -229,7 +228,6 @@ func (s *erasureSets) connectDisks() { } if disk.IsLocal() && disk.Healing() != nil { globalBackgroundHealState.pushHealLocalDisks(disk.Endpoint()) - logger.Info(fmt.Sprintf("Found the drive %s that needs healing, attempting to heal...", disk)) } s.erasureDisksMu.RLock() setIndex, diskIndex, err := findDiskIndex(s.format, format) @@ -1256,9 +1254,7 @@ func markRootDisksAsDown(storageDisks []StorageAPI, errs []error) { if storageDisks[i] != nil && infos[i].RootDisk { // We should not heal on root disk. i.e in a situation where the minio-administrator has unmounted a // defective drive we should not heal a path on the root disk. - logger.Info("Disk `%s` the same as the system root disk.\n"+ - "Disk will not be used. Please supply a separate disk and restart the server.", - storageDisks[i].String()) + logger.LogIf(GlobalContext, fmt.Errorf("Disk `%s` is part of root disk, will not be used", storageDisks[i])) storageDisks[i] = nil } } diff --git a/cmd/erasure.go b/cmd/erasure.go index 3a7110fb9..e7047f6cf 100644 --- a/cmd/erasure.go +++ b/cmd/erasure.go @@ -29,7 +29,6 @@ import ( "github.com/minio/madmin-go" "github.com/minio/minio/internal/bpool" - "github.com/minio/minio/internal/color" "github.com/minio/minio/internal/dsync" "github.com/minio/minio/internal/logger" "github.com/minio/minio/internal/sync/errgroup" @@ -353,7 +352,7 @@ func (er erasureObjects) nsScanner(ctx context.Context, buckets []BucketInfo, bf // Collect disks we can use. disks, healing := er.getOnlineDisksWithHealing() if len(disks) == 0 { - logger.Info(color.Green("data-scanner:") + " all disks are offline or being healed, skipping scanner") + logger.LogIf(ctx, errors.New("data-scanner: all disks are offline or being healed, skipping scanner cycle")) return nil } diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index e3298b574..b257f959d 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -377,7 +377,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) { } // TODO: remove the following line by June 1st. - logStartupMessage( + logger.Info( color.RedBold(` =================================================================================== **** WARNING: MinIO Gateway will be removed by June 1st from MinIO repository ***** diff --git a/cmd/gateway-startup-msg.go b/cmd/gateway-startup-msg.go index 77c15576a..3a5724aa2 100644 --- a/cmd/gateway-startup-msg.go +++ b/cmd/gateway-startup-msg.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/minio/minio/internal/color" + "github.com/minio/minio/internal/logger" ) // Prints the formatted startup message. @@ -45,7 +46,7 @@ func printGatewayStartupMessage(apiEndPoints []string, backendType string) { if globalMinioConsolePortAuto && globalBrowserEnabled { msg := fmt.Sprintf("\nWARNING: Console endpoint is listening on a dynamic port (%s), please use --console-address \":PORT\" to choose a static port.", globalMinioConsolePort) - logStartupMessage(color.RedBold(msg)) + logger.Info(color.RedBold(msg)) } } @@ -57,19 +58,19 @@ func printGatewayCommonMsg(apiEndpoints []string) { apiEndpointStr := strings.Join(apiEndpoints, " ") // Colorize the message and print. - logStartupMessage(color.Blue("API: ") + color.Bold(fmt.Sprintf("%s ", apiEndpointStr))) + logger.Info(color.Blue("API: ") + color.Bold(fmt.Sprintf("%s ", apiEndpointStr))) if color.IsTerminal() && !globalCLIContext.Anonymous { - logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) - logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) + logger.Info(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) + logger.Info(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) } printEventNotifiers() if globalBrowserEnabled { consoleEndpointStr := strings.Join(stripStandardPorts(getConsoleEndpoints(), globalMinioConsoleHost), " ") - logStartupMessage(color.Blue("\nConsole: ") + color.Bold(fmt.Sprintf("%s ", consoleEndpointStr))) + logger.Info(color.Blue("\nConsole: ") + color.Bold(fmt.Sprintf("%s ", consoleEndpointStr))) if color.IsTerminal() && !globalCLIContext.Anonymous { - logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) - logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) + logger.Info(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) + logger.Info(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) } } } diff --git a/cmd/global-heal.go b/cmd/global-heal.go index 292d6b53d..19f7861c3 100644 --- a/cmd/global-heal.go +++ b/cmd/global-heal.go @@ -330,8 +330,6 @@ func (er *erasureObjects) healErasureSet(ctx context.Context, buckets []string, default: tracker.bucketDone(bucket) logger.LogIf(ctx, tracker.update(ctx)) - logger.Info("Healing bucket %s content on %s erasure set complete", - bucket, humanize.Ordinal(tracker.SetIndex+1)) } } tracker.Object = "" diff --git a/cmd/iam.go b/cmd/iam.go index 7371b20dc..f8a83dc12 100644 --- a/cmd/iam.go +++ b/cmd/iam.go @@ -349,7 +349,7 @@ func (sys *IAMSys) printIAMRoles() { msgs = append(msgs, color.Bold(arn)) } - logStartupMessage(fmt.Sprintf("%s %s", color.Blue("IAM Roles:"), strings.Join(msgs, " "))) + logger.Info(fmt.Sprintf("%s %s", color.Blue("IAM Roles:"), strings.Join(msgs, " "))) } // HasWatcher - returns if the IAM system has a watcher to be notified of diff --git a/cmd/main.go b/cmd/main.go index 26b1a2f39..cba9fdfff 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -44,7 +44,7 @@ var GlobalFlags = []cli.Flag{ }, cli.BoolFlag{ Name: "quiet", - Usage: "disable startup information", + Usage: "disable startup and info messages", }, cli.BoolFlag{ Name: "anonymous", @@ -52,7 +52,7 @@ var GlobalFlags = []cli.Flag{ }, cli.BoolFlag{ Name: "json", - Usage: "output server logs and startup information in json format", + Usage: "output logs in JSON format", }, // Deprecated flag, so its hidden now, existing deployments will keep working. cli.BoolFlag{ diff --git a/cmd/server-main.go b/cmd/server-main.go index 2056678c9..b550e8bad 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -507,11 +507,11 @@ func serverMain(ctx *cli.Context) { if globalActiveCred.Equal(auth.DefaultCredentials) { msg := fmt.Sprintf("WARNING: Detected default credentials '%s', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables", globalActiveCred) - logStartupMessage(color.RedBold(msg)) + logger.Info(color.RedBold(msg)) } if !globalCLIContext.StrictS3Compat { - logStartupMessage(color.RedBold("WARNING: Strict AWS S3 compatible incoming PUT, POST content payload validation is turned off, caution is advised do not use in production")) + logger.Info(color.RedBold("WARNING: Strict AWS S3 compatible incoming PUT, POST content payload validation is turned off, caution is advised do not use in production")) } if err = initServer(GlobalContext, newObject); err != nil { @@ -595,7 +595,7 @@ func serverMain(ctx *cli.Context) { // initialize the new disk cache objects. if globalCacheConfig.Enabled { - logStartupMessage(color.Yellow("WARNING: Disk caching is deprecated for single/multi drive MinIO setups. Please migrate to using MinIO S3 gateway instead of disk caching")) + logger.Info(color.Yellow("WARNING: Disk caching is deprecated for single/multi drive MinIO setups. Please migrate to using MinIO S3 gateway instead of disk caching")) var cacheAPI CacheObjectLayer cacheAPI, err = newServerCacheObjects(GlobalContext, globalCacheConfig) logger.FatalIf(err, "Unable to initialize disk caching") diff --git a/cmd/server-rlimit.go b/cmd/server-rlimit.go index abb5089d8..ec3acb3cd 100644 --- a/cmd/server-rlimit.go +++ b/cmd/server-rlimit.go @@ -44,7 +44,8 @@ func setMaxResources() (err error) { } if maxLimit < 4096 && runtime.GOOS != globalWindowsOSName { - logger.Info("WARNING: maximum file descriptor limit %d is too low for production servers. At least 4096 is recommended. Fix with \"ulimit -n 4096\"", maxLimit) + logger.Info("WARNING: maximum file descriptor limit %d is too low for production servers. At least 4096 is recommended. Fix with \"ulimit -n 4096\"", + maxLimit) } if err = sys.SetMaxOpenFileLimit(maxLimit, maxLimit); err != nil { diff --git a/cmd/server-startup-msg.go b/cmd/server-startup-msg.go index 1dabc5fde..e4b9f7a98 100644 --- a/cmd/server-startup-msg.go +++ b/cmd/server-startup-msg.go @@ -45,9 +45,9 @@ func mustGetStorageInfo(objAPI ObjectLayer) StorageInfo { // Prints the formatted startup message. func printStartupMessage(apiEndpoints []string, err error) { if err != nil { - logStartupMessage(color.RedBold("Server startup failed with '%v'", err)) - logStartupMessage(color.RedBold("Not all features may be available on this server")) - logStartupMessage(color.RedBold("Please use 'mc admin' commands to further investigate this issue")) + if globalConsoleSys != nil { + globalConsoleSys.Send(fmt.Sprintf("Server startup failed with '%v', some features may be missing", err), string(logger.All)) + } } strippedAPIEndpoints := stripStandardPorts(apiEndpoints, globalMinioHost) @@ -76,7 +76,7 @@ func printStartupMessage(apiEndpoints []string, err error) { if globalMinioConsolePortAuto && globalBrowserEnabled { msg := fmt.Sprintf("\nWARNING: Console endpoint is listening on a dynamic port (%s), please use --console-address \":PORT\" to choose a static port.", globalMinioConsolePort) - logStartupMessage(color.RedBold(msg)) + logger.Info(color.RedBold(msg)) } } @@ -131,29 +131,29 @@ func printServerCommonMsg(apiEndpoints []string) { apiEndpointStr := strings.Join(apiEndpoints, " ") // Colorize the message and print. - logStartupMessage(color.Blue("API: ") + color.Bold(fmt.Sprintf("%s ", apiEndpointStr))) - if color.IsTerminal() && !globalCLIContext.Anonymous { - logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) - logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) + logger.Info(color.Blue("API: ") + color.Bold(fmt.Sprintf("%s ", apiEndpointStr))) + if color.IsTerminal() && (!globalCLIContext.Anonymous && !globalCLIContext.JSON) { + logger.Info(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) + logger.Info(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) if region != "" { - logStartupMessage(color.Blue("Region: ") + color.Bold(fmt.Sprintf(getFormatStr(len(region), 2), region))) + logger.Info(color.Blue("Region: ") + color.Bold(fmt.Sprintf(getFormatStr(len(region), 2), region))) } } printEventNotifiers() if globalBrowserEnabled { consoleEndpointStr := strings.Join(stripStandardPorts(getConsoleEndpoints(), globalMinioConsoleHost), " ") - logStartupMessage(color.Blue("\nConsole: ") + color.Bold(fmt.Sprintf("%s ", consoleEndpointStr))) - if color.IsTerminal() && !globalCLIContext.Anonymous { - logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) - logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) + logger.Info(color.Blue("\nConsole: ") + color.Bold(fmt.Sprintf("%s ", consoleEndpointStr))) + if color.IsTerminal() && (!globalCLIContext.Anonymous && !globalCLIContext.JSON) { + logger.Info(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) + logger.Info(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) } } } // Prints startup message for Object API acces, prints link to our SDK documentation. func printObjectAPIMsg() { - logStartupMessage(color.Blue("\nDocumentation: ") + "https://docs.min.io") + logger.Info(color.Blue("\nDocumentation: ") + "https://docs.min.io") } // Prints bucket notification configurations. @@ -172,7 +172,7 @@ func printEventNotifiers() { arnMsg += color.Bold(fmt.Sprintf("%s ", arn)) } - logStartupMessage(arnMsg) + logger.Info(arnMsg) } // Prints startup message for command line access. Prints link to our documentation @@ -185,15 +185,15 @@ func printCLIAccessMsg(endPoint string, alias string) { // Configure 'mc', following block prints platform specific information for minio client. if color.IsTerminal() && !globalCLIContext.Anonymous { - logStartupMessage(color.Blue("\nCommand-line: ") + mcQuickStartGuide) + logger.Info(color.Blue("\nCommand-line: ") + mcQuickStartGuide) if runtime.GOOS == globalWindowsOSName { mcMessage := fmt.Sprintf("$ mc.exe alias set %s %s %s %s", alias, endPoint, cred.AccessKey, cred.SecretKey) - logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) + logger.Info(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) } else { mcMessage := fmt.Sprintf("$ mc alias set %s %s %s %s", alias, endPoint, cred.AccessKey, cred.SecretKey) - logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) + logger.Info(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) } } } @@ -220,10 +220,7 @@ func getStorageInfoMsg(storageInfo StorageInfo) string { // Prints startup message of storage capacity and erasure information. func printStorageInfo(storageInfo StorageInfo) { if msg := getStorageInfoMsg(storageInfo); msg != "" { - if globalCLIContext.Quiet { - logger.Info(msg) - } - logStartupMessage(msg) + logger.Info(msg) } } @@ -231,5 +228,5 @@ func printCacheStorageInfo(storageInfo CacheStorageInfo) { msg := fmt.Sprintf("%s %s Free, %s Total", color.Blue("Cache Capacity:"), humanize.IBytes(storageInfo.Free), humanize.IBytes(storageInfo.Total)) - logStartupMessage(msg) + logger.Info(msg) } diff --git a/cmd/site-replication.go b/cmd/site-replication.go index 57d9d84a4..1c69d4e14 100644 --- a/cmd/site-replication.go +++ b/cmd/site-replication.go @@ -189,7 +189,7 @@ func (c *SiteReplicationSys) Init(ctx context.Context, objAPI ObjectLayer) error c.RLock() defer c.RUnlock() if c.enabled { - logger.Info("Cluster Replication initialized.") + logger.Info("Cluster replication initialized") } return err diff --git a/cmd/update-notifier.go b/cmd/update-notifier.go index cc726c546..fa5d59674 100644 --- a/cmd/update-notifier.go +++ b/cmd/update-notifier.go @@ -41,6 +41,10 @@ func prepareUpdateMessage(downloadURL string, older time.Duration) string { t := time.Time{} newerThan := humanize.RelTime(t, t.Add(older), "ago", "") + if globalCLIContext.JSON { + return fmt.Sprintf("You are running an older version of MinIO released %s, update: %s", newerThan, downloadURL) + } + // Return the nicely colored and formatted update message. return colorizeUpdateMessage(downloadURL, newerThan) } diff --git a/cmd/xl-storage-format-v2.go b/cmd/xl-storage-format-v2.go index 6cbaa584b..b07005c24 100644 --- a/cmd/xl-storage-format-v2.go +++ b/cmd/xl-storage-format-v2.go @@ -880,7 +880,7 @@ func (x *xlMetaV2) loadIndexed(buf xlMetaBuf, data xlMetaInlineData) error { x.metaV = metaV if err = x.data.validate(); err != nil { x.data.repair() - logger.Info("xlMetaV2.loadIndexed: data validation failed: %v. %d entries after repair", err, x.data.entries()) + logger.LogIf(GlobalContext, fmt.Errorf("xlMetaV2.loadIndexed: data validation failed: %v. %d entries after repair", err, x.data.entries())) } return decodeVersions(buf, versions, func(i int, hdr, meta []byte) error { @@ -929,7 +929,7 @@ func (x *xlMetaV2) loadLegacy(buf []byte) error { x.data = buf if err = x.data.validate(); err != nil { x.data.repair() - logger.Info("xlMetaV2.Load: data validation failed: %v. %d entries after repair", err, x.data.entries()) + logger.LogIf(GlobalContext, fmt.Errorf("xlMetaV2.Load: data validation failed: %v. %d entries after repair", err, x.data.entries())) } default: return errors.New("unknown minor metadata version") diff --git a/internal/logger/console.go b/internal/logger/console.go index 12c816190..2e6c3de21 100644 --- a/internal/logger/console.go +++ b/internal/logger/console.go @@ -169,7 +169,6 @@ func (i infoMsg) json(msg string, args ...interface{}) { } func (i infoMsg) quiet(msg string, args ...interface{}) { - i.pretty(msg, args...) } func (i infoMsg) pretty(msg string, args ...interface{}) { @@ -222,22 +221,3 @@ func Error(msg string, data ...interface{}) { func Info(msg string, data ...interface{}) { consoleLog(info, msg, data...) } - -var startupMessage startUpMsg - -type startUpMsg struct{} - -func (s startUpMsg) json(msg string, args ...interface{}) { -} - -func (s startUpMsg) quiet(msg string, args ...interface{}) { -} - -func (s startUpMsg) pretty(msg string, args ...interface{}) { - c.Printf(msg, args...) -} - -// StartupMessage : -func StartupMessage(msg string, data ...interface{}) { - consoleLog(startupMessage, msg, data...) -}