improve logs, fix banner formatting (#14456)

This commit is contained in:
Harshavardhana 2022-03-03 13:21:16 -08:00 committed by GitHub
parent b48f719b8e
commit 0e3bafcc54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 73 additions and 100 deletions

View file

@ -263,7 +263,7 @@ func initAutoHeal(ctx context.Context, objAPI ObjectLayer) {
globalBackgroundHealState.pushHealLocalDisks(getLocalDisksToHeal()...) globalBackgroundHealState.pushHealLocalDisks(getLocalDisksToHeal()...)
if drivesToHeal := globalBackgroundHealState.healDriveCount(); drivesToHeal > 0 { 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)) drivesToHeal, defaultMonitorNewDiskInterval))
// Heal any disk format and metadata early, if possible. // 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 // Ensure that reformatting disks is finished
bgSeq.queueHealTask(healSource{bucket: nopHeal}, madmin.HealItemMetadata) 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))) len(healDisks)))
erasureSetInPoolDisksToHeal = make([]map[int][]StorageAPI, len(z.serverPools)) 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) { go func(setIndex int, disks []StorageAPI) {
defer wg.Done() defer wg.Done()
for _, disk := range disks { 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. // So someone changed the drives underneath, healing tracker missing.
tracker, err := loadHealingTracker(ctx, disk) tracker, err := loadHealingTracker(ctx, disk)
if err != nil { if err != nil {
logger.Info("Healing tracker missing on '%s', disk was swapped again on %s pool", logger.LogIf(ctx, fmt.Errorf("Healing tracker missing on '%s', disk was swapped again on %s pool: %w",
disk, humanize.Ordinal(i+1)) disk, humanize.Ordinal(i+1), err))
tracker = newHealingTracker(disk) tracker = newHealingTracker(disk)
} }
@ -438,12 +440,14 @@ func monitorLocalDisksAndHeal(ctx context.Context, z *erasureServerPools, bgSeq
continue continue
} }
logger.Info("Healing disk '%s' on %s pool, %s set complete", disk, if serverDebugLog {
humanize.Ordinal(i+1), humanize.Ordinal(setIndex+1)) logger.Info("Healing disk '%s' on %s pool, %s set complete", disk,
logger.Info("Summary:\n") humanize.Ordinal(i+1), humanize.Ordinal(setIndex+1))
tracker.printTo(os.Stdout) logger.Info("Summary:\n")
tracker.printTo(os.Stdout)
logger.Info("\n")
}
logger.LogIf(ctx, tracker.delete(ctx)) logger.LogIf(ctx, tracker.delete(ctx))
logger.Info("\n")
// Only upon success pop the healed disk. // Only upon success pop the healed disk.
globalBackgroundHealState.popHealLocalDisks(disk.Endpoint()) globalBackgroundHealState.popHealLocalDisks(disk.Endpoint())

View file

@ -206,7 +206,7 @@ func verifyServerSystemConfig(ctx context.Context, endpointServerPools EndpointS
for _, clnt := range clnts { for _, clnt := range clnts {
if err := clnt.Verify(ctx, srcCfg); err != nil { if err := clnt.Verify(ctx, srcCfg); err != nil {
if !isNetworkError(err) { 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()) offlineEndpoints = append(offlineEndpoints, clnt.String())
continue continue

View file

@ -327,7 +327,7 @@ func checkUpdate(mode string) {
return 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) { func newConfigDirFromCtx(ctx *cli.Context, option string, getDefaultDir func() string) (*ConfigDir, bool) {
@ -762,7 +762,7 @@ func handleCommonEnvVars() {
" Please use %s and %s", " Please use %s and %s",
config.EnvAccessKey, config.EnvSecretKey, config.EnvAccessKey, config.EnvSecretKey,
config.EnvRootUser, config.EnvRootPassword) config.EnvRootUser, config.EnvRootPassword)
logStartupMessage(color.RedBold(msg)) logger.Info(color.RedBold(msg))
} }
globalActiveCred = cred 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) { func getTLSConfig() (x509Certs []*x509.Certificate, manager *certs.Manager, secureConn bool, err error) {
if !(isFile(getPublicCertFile()) && isFile(getPrivateKeyFile())) { if !(isFile(getPublicCertFile()) && isFile(getPrivateKeyFile())) {
return nil, nil, false, nil return nil, nil, false, nil

View file

@ -529,7 +529,7 @@ func lookupConfigs(s config.Config, objAPI ObjectLayer) {
} }
if globalSTSTLSConfig.InsecureSkipVerify { 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], globalOpenIDConfig, err = openid.LookupConfig(s[config.IdentityOpenIDSubSys][config.Default],

View file

@ -74,7 +74,7 @@ func migrateIAMConfigsEtcdToEncrypted(ctx context.Context, client *etcd.Client)
if err != nil { if err != nil {
return err 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) listCtx, cancel := context.WithTimeout(ctx, 1*time.Minute)
@ -143,7 +143,7 @@ func migrateConfigPrefixToEncrypted(objAPI ObjectLayer, encrypted bool) error {
if err != nil { if err != nil {
return err 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 var marker string

View file

@ -24,6 +24,7 @@ import (
"crypto/rand" "crypto/rand"
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
"errors"
"fmt" "fmt"
"io" "io"
"io/ioutil" "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. // 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. // If current usage without size exceeds high watermark a GC is automatically queued.
func (c *diskCache) diskSpaceAvailable(size int64) bool { 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 gcTriggerPct := c.quotaPct * c.highWatermark / 100
di, err := disk.GetInfo(c.dir) di, err := disk.GetInfo(c.dir)
if err != nil { if err != nil {
reqInfo := (&logger.ReqInfo{}).AppendTags("cachePath", c.dir)
ctx := logger.SetReqInfo(GlobalContext, reqInfo)
logger.LogIf(ctx, err) logger.LogIf(ctx, err)
return false return false
} }
if di.Total == 0 { 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 return false
} }
usedPercent := float64(di.Used) * 100 / float64(di.Total) usedPercent := float64(di.Used) * 100 / float64(di.Total)

View file

@ -614,7 +614,7 @@ func newCache(config cache.Config) ([]*diskCache, bool, error) {
} }
func (c *cacheObjects) migrateCacheFromV1toV2(ctx context.Context) { 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)) g := errgroup.WithNErrs(len(c.cache))
for index, dc := range c.cache { for index, dc := range c.cache {
@ -643,7 +643,7 @@ func (c *cacheObjects) migrateCacheFromV1toV2(ctx context.Context) {
// update migration status // update migration status
c.migrating = false 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 // PutObject - caches the uploaded object for single Put operations

View file

@ -343,10 +343,8 @@ func (er erasureObjects) getObjectWithFileInfo(ctx context.Context, bucket, obje
switch { switch {
case errors.Is(err, errFileNotFound): case errors.Is(err, errFileNotFound):
scan = madmin.HealNormalScan scan = madmin.HealNormalScan
logger.Info("Healing required, triggering async heal missing shards for %s", pathJoin(bucket, object, fi.VersionID))
case errors.Is(err, errFileCorrupt): case errors.Is(err, errFileCorrupt):
scan = madmin.HealDeepScan scan = madmin.HealDeepScan
logger.Info("Healing required, triggering async heal bitrot for %s", pathJoin(bucket, object, fi.VersionID))
} }
switch scan { switch scan {
case madmin.HealNormalScan, madmin.HealDeepScan: case madmin.HealNormalScan, madmin.HealDeepScan:

View file

@ -221,7 +221,6 @@ func (s *erasureSets) connectDisks() {
if err != nil { if err != nil {
if endpoint.IsLocal && errors.Is(err, errUnformattedDisk) { if endpoint.IsLocal && errors.Is(err, errUnformattedDisk) {
globalBackgroundHealState.pushHealLocalDisks(endpoint) globalBackgroundHealState.pushHealLocalDisks(endpoint)
logger.Info(fmt.Sprintf("Found unformatted drive %s, attempting to heal...", endpoint))
} else { } else {
printEndpointError(endpoint, err, true) printEndpointError(endpoint, err, true)
} }
@ -229,7 +228,6 @@ func (s *erasureSets) connectDisks() {
} }
if disk.IsLocal() && disk.Healing() != nil { if disk.IsLocal() && disk.Healing() != nil {
globalBackgroundHealState.pushHealLocalDisks(disk.Endpoint()) globalBackgroundHealState.pushHealLocalDisks(disk.Endpoint())
logger.Info(fmt.Sprintf("Found the drive %s that needs healing, attempting to heal...", disk))
} }
s.erasureDisksMu.RLock() s.erasureDisksMu.RLock()
setIndex, diskIndex, err := findDiskIndex(s.format, format) setIndex, diskIndex, err := findDiskIndex(s.format, format)
@ -1256,9 +1254,7 @@ func markRootDisksAsDown(storageDisks []StorageAPI, errs []error) {
if storageDisks[i] != nil && infos[i].RootDisk { 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 // 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. // defective drive we should not heal a path on the root disk.
logger.Info("Disk `%s` the same as the system root disk.\n"+ logger.LogIf(GlobalContext, fmt.Errorf("Disk `%s` is part of root disk, will not be used", storageDisks[i]))
"Disk will not be used. Please supply a separate disk and restart the server.",
storageDisks[i].String())
storageDisks[i] = nil storageDisks[i] = nil
} }
} }

View file

@ -29,7 +29,6 @@ import (
"github.com/minio/madmin-go" "github.com/minio/madmin-go"
"github.com/minio/minio/internal/bpool" "github.com/minio/minio/internal/bpool"
"github.com/minio/minio/internal/color"
"github.com/minio/minio/internal/dsync" "github.com/minio/minio/internal/dsync"
"github.com/minio/minio/internal/logger" "github.com/minio/minio/internal/logger"
"github.com/minio/minio/internal/sync/errgroup" "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. // Collect disks we can use.
disks, healing := er.getOnlineDisksWithHealing() disks, healing := er.getOnlineDisksWithHealing()
if len(disks) == 0 { 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 return nil
} }

View file

@ -377,7 +377,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
} }
// TODO: remove the following line by June 1st. // TODO: remove the following line by June 1st.
logStartupMessage( logger.Info(
color.RedBold(` color.RedBold(`
=================================================================================== ===================================================================================
**** WARNING: MinIO Gateway will be removed by June 1st from MinIO repository ***** **** WARNING: MinIO Gateway will be removed by June 1st from MinIO repository *****

View file

@ -22,6 +22,7 @@ import (
"strings" "strings"
"github.com/minio/minio/internal/color" "github.com/minio/minio/internal/color"
"github.com/minio/minio/internal/logger"
) )
// Prints the formatted startup message. // Prints the formatted startup message.
@ -45,7 +46,7 @@ func printGatewayStartupMessage(apiEndPoints []string, backendType string) {
if globalMinioConsolePortAuto && globalBrowserEnabled { 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.", msg := fmt.Sprintf("\nWARNING: Console endpoint is listening on a dynamic port (%s), please use --console-address \":PORT\" to choose a static port.",
globalMinioConsolePort) globalMinioConsolePort)
logStartupMessage(color.RedBold(msg)) logger.Info(color.RedBold(msg))
} }
} }
@ -57,19 +58,19 @@ func printGatewayCommonMsg(apiEndpoints []string) {
apiEndpointStr := strings.Join(apiEndpoints, " ") apiEndpointStr := strings.Join(apiEndpoints, " ")
// Colorize the message and print. // 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 { if color.IsTerminal() && !globalCLIContext.Anonymous {
logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) logger.Info(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("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey)))
} }
printEventNotifiers() printEventNotifiers()
if globalBrowserEnabled { if globalBrowserEnabled {
consoleEndpointStr := strings.Join(stripStandardPorts(getConsoleEndpoints(), globalMinioConsoleHost), " ") 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 { if color.IsTerminal() && !globalCLIContext.Anonymous {
logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) logger.Info(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("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey)))
} }
} }
} }

View file

@ -330,8 +330,6 @@ func (er *erasureObjects) healErasureSet(ctx context.Context, buckets []string,
default: default:
tracker.bucketDone(bucket) tracker.bucketDone(bucket)
logger.LogIf(ctx, tracker.update(ctx)) 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 = "" tracker.Object = ""

View file

@ -349,7 +349,7 @@ func (sys *IAMSys) printIAMRoles() {
msgs = append(msgs, color.Bold(arn)) 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 // HasWatcher - returns if the IAM system has a watcher to be notified of

View file

@ -44,7 +44,7 @@ var GlobalFlags = []cli.Flag{
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "quiet", Name: "quiet",
Usage: "disable startup information", Usage: "disable startup and info messages",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "anonymous", Name: "anonymous",
@ -52,7 +52,7 @@ var GlobalFlags = []cli.Flag{
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "json", 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. // Deprecated flag, so its hidden now, existing deployments will keep working.
cli.BoolFlag{ cli.BoolFlag{

View file

@ -507,11 +507,11 @@ func serverMain(ctx *cli.Context) {
if globalActiveCred.Equal(auth.DefaultCredentials) { 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", 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) globalActiveCred)
logStartupMessage(color.RedBold(msg)) logger.Info(color.RedBold(msg))
} }
if !globalCLIContext.StrictS3Compat { 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 { if err = initServer(GlobalContext, newObject); err != nil {
@ -595,7 +595,7 @@ func serverMain(ctx *cli.Context) {
// initialize the new disk cache objects. // initialize the new disk cache objects.
if globalCacheConfig.Enabled { 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 var cacheAPI CacheObjectLayer
cacheAPI, err = newServerCacheObjects(GlobalContext, globalCacheConfig) cacheAPI, err = newServerCacheObjects(GlobalContext, globalCacheConfig)
logger.FatalIf(err, "Unable to initialize disk caching") logger.FatalIf(err, "Unable to initialize disk caching")

View file

@ -44,7 +44,8 @@ func setMaxResources() (err error) {
} }
if maxLimit < 4096 && runtime.GOOS != globalWindowsOSName { 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 { if err = sys.SetMaxOpenFileLimit(maxLimit, maxLimit); err != nil {

View file

@ -45,9 +45,9 @@ func mustGetStorageInfo(objAPI ObjectLayer) StorageInfo {
// Prints the formatted startup message. // Prints the formatted startup message.
func printStartupMessage(apiEndpoints []string, err error) { func printStartupMessage(apiEndpoints []string, err error) {
if err != nil { if err != nil {
logStartupMessage(color.RedBold("Server startup failed with '%v'", err)) if globalConsoleSys != nil {
logStartupMessage(color.RedBold("Not all features may be available on this server")) globalConsoleSys.Send(fmt.Sprintf("Server startup failed with '%v', some features may be missing", err), string(logger.All))
logStartupMessage(color.RedBold("Please use 'mc admin' commands to further investigate this issue")) }
} }
strippedAPIEndpoints := stripStandardPorts(apiEndpoints, globalMinioHost) strippedAPIEndpoints := stripStandardPorts(apiEndpoints, globalMinioHost)
@ -76,7 +76,7 @@ func printStartupMessage(apiEndpoints []string, err error) {
if globalMinioConsolePortAuto && globalBrowserEnabled { 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.", msg := fmt.Sprintf("\nWARNING: Console endpoint is listening on a dynamic port (%s), please use --console-address \":PORT\" to choose a static port.",
globalMinioConsolePort) globalMinioConsolePort)
logStartupMessage(color.RedBold(msg)) logger.Info(color.RedBold(msg))
} }
} }
@ -131,29 +131,29 @@ func printServerCommonMsg(apiEndpoints []string) {
apiEndpointStr := strings.Join(apiEndpoints, " ") apiEndpointStr := strings.Join(apiEndpoints, " ")
// Colorize the message and print. // 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 { if color.IsTerminal() && (!globalCLIContext.Anonymous && !globalCLIContext.JSON) {
logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) logger.Info(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("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey)))
if region != "" { 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() printEventNotifiers()
if globalBrowserEnabled { if globalBrowserEnabled {
consoleEndpointStr := strings.Join(stripStandardPorts(getConsoleEndpoints(), globalMinioConsoleHost), " ") 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 { if color.IsTerminal() && (!globalCLIContext.Anonymous && !globalCLIContext.JSON) {
logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) logger.Info(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("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey)))
} }
} }
} }
// Prints startup message for Object API acces, prints link to our SDK documentation. // Prints startup message for Object API acces, prints link to our SDK documentation.
func printObjectAPIMsg() { func printObjectAPIMsg() {
logStartupMessage(color.Blue("\nDocumentation: ") + "https://docs.min.io") logger.Info(color.Blue("\nDocumentation: ") + "https://docs.min.io")
} }
// Prints bucket notification configurations. // Prints bucket notification configurations.
@ -172,7 +172,7 @@ func printEventNotifiers() {
arnMsg += color.Bold(fmt.Sprintf("%s ", arn)) arnMsg += color.Bold(fmt.Sprintf("%s ", arn))
} }
logStartupMessage(arnMsg) logger.Info(arnMsg)
} }
// Prints startup message for command line access. Prints link to our documentation // 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. // Configure 'mc', following block prints platform specific information for minio client.
if color.IsTerminal() && !globalCLIContext.Anonymous { if color.IsTerminal() && !globalCLIContext.Anonymous {
logStartupMessage(color.Blue("\nCommand-line: ") + mcQuickStartGuide) logger.Info(color.Blue("\nCommand-line: ") + mcQuickStartGuide)
if runtime.GOOS == globalWindowsOSName { if runtime.GOOS == globalWindowsOSName {
mcMessage := fmt.Sprintf("$ mc.exe alias set %s %s %s %s", alias, mcMessage := fmt.Sprintf("$ mc.exe alias set %s %s %s %s", alias,
endPoint, cred.AccessKey, cred.SecretKey) endPoint, cred.AccessKey, cred.SecretKey)
logStartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) logger.Info(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
} else { } else {
mcMessage := fmt.Sprintf("$ mc alias set %s %s %s %s", alias, mcMessage := fmt.Sprintf("$ mc alias set %s %s %s %s", alias,
endPoint, cred.AccessKey, cred.SecretKey) 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. // Prints startup message of storage capacity and erasure information.
func printStorageInfo(storageInfo StorageInfo) { func printStorageInfo(storageInfo StorageInfo) {
if msg := getStorageInfoMsg(storageInfo); msg != "" { if msg := getStorageInfoMsg(storageInfo); msg != "" {
if globalCLIContext.Quiet { logger.Info(msg)
logger.Info(msg)
}
logStartupMessage(msg)
} }
} }
@ -231,5 +228,5 @@ func printCacheStorageInfo(storageInfo CacheStorageInfo) {
msg := fmt.Sprintf("%s %s Free, %s Total", color.Blue("Cache Capacity:"), msg := fmt.Sprintf("%s %s Free, %s Total", color.Blue("Cache Capacity:"),
humanize.IBytes(storageInfo.Free), humanize.IBytes(storageInfo.Free),
humanize.IBytes(storageInfo.Total)) humanize.IBytes(storageInfo.Total))
logStartupMessage(msg) logger.Info(msg)
} }

View file

@ -189,7 +189,7 @@ func (c *SiteReplicationSys) Init(ctx context.Context, objAPI ObjectLayer) error
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
if c.enabled { if c.enabled {
logger.Info("Cluster Replication initialized.") logger.Info("Cluster replication initialized")
} }
return err return err

View file

@ -41,6 +41,10 @@ func prepareUpdateMessage(downloadURL string, older time.Duration) string {
t := time.Time{} t := time.Time{}
newerThan := humanize.RelTime(t, t.Add(older), "ago", "") 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 the nicely colored and formatted update message.
return colorizeUpdateMessage(downloadURL, newerThan) return colorizeUpdateMessage(downloadURL, newerThan)
} }

View file

@ -880,7 +880,7 @@ func (x *xlMetaV2) loadIndexed(buf xlMetaBuf, data xlMetaInlineData) error {
x.metaV = metaV x.metaV = metaV
if err = x.data.validate(); err != nil { if err = x.data.validate(); err != nil {
x.data.repair() 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 { 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 x.data = buf
if err = x.data.validate(); err != nil { if err = x.data.validate(); err != nil {
x.data.repair() 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: default:
return errors.New("unknown minor metadata version") return errors.New("unknown minor metadata version")

View file

@ -169,7 +169,6 @@ func (i infoMsg) json(msg string, args ...interface{}) {
} }
func (i infoMsg) quiet(msg string, args ...interface{}) { func (i infoMsg) quiet(msg string, args ...interface{}) {
i.pretty(msg, args...)
} }
func (i infoMsg) pretty(msg string, args ...interface{}) { func (i infoMsg) pretty(msg string, args ...interface{}) {
@ -222,22 +221,3 @@ func Error(msg string, data ...interface{}) {
func Info(msg string, data ...interface{}) { func Info(msg string, data ...interface{}) {
consoleLog(info, msg, data...) 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...)
}