Modify fatalIf, startup and update message logging code (#5780)

Use a common logging framework to log fatalIf, startup, Info and Update
messages.
master
kannappanr 7 years ago committed by GitHub
parent cef992a395
commit 57a3d9c16c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cmd/common-main.go
  2. 46
      cmd/config-migrate.go
  3. 2
      cmd/gateway-main.go
  4. 10
      cmd/gateway-startup-msg.go
  5. 6
      cmd/gateway/sia/gateway-sia.go
  6. 204
      cmd/logger/logger.go
  7. 5
      cmd/prepare-storage.go
  8. 39
      cmd/server-startup-msg.go
  9. 6
      cmd/signals.go
  10. 10
      cmd/update-main.go

@ -34,9 +34,9 @@ func checkUpdate(mode string) {
// Its OK to ignore any errors during doUpdate() here.
if updateMsg, _, currentReleaseTime, latestReleaseTime, err := getUpdateInfo(2*time.Second, mode); err == nil {
if globalInplaceUpdateDisabled {
logger.Println(updateMsg)
logger.StartupMessage(updateMsg)
} else {
logger.Println(prepareUpdateMessage("Run `minio update`", latestReleaseTime.Sub(currentReleaseTime)))
logger.StartupMessage(prepareUpdateMessage("Run `minio update`", latestReleaseTime.Sub(currentReleaseTime)))
}
}
}
@ -48,7 +48,7 @@ func initConfig() {
logger.FatalIf(loadConfig(), "Unable to load config version: '%s'.", serverConfigVersion)
} else {
logger.FatalIf(newConfig(), "Unable to initialize minio config for the first time.")
logger.Println("Created minio configuration file successfully at " + getConfigDir())
logger.Info("Created minio configuration file successfully at " + getConfigDir())
}
}

@ -30,7 +30,7 @@ import (
)
// DO NOT EDIT following message template, please open a github issue to discuss instead.
var configMigrateMSGTemplate = "Configuration file %s migrated from version '%s' to '%s' successfully.\n"
var configMigrateMSGTemplate = "Configuration file %s migrated from version '%s' to '%s' successfully."
// Migrates all config versions from "1" to "18".
func migrateConfig() error {
@ -195,7 +195,7 @@ func purgeV1() error {
}
os.RemoveAll(configFile)
logger.Println("Removed unsupported config version ‘1’.")
logger.Info("Removed unsupported config version ‘1’.")
return nil
}
@ -253,7 +253,7 @@ func migrateV2ToV3() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv2.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version)
return nil
}
@ -291,7 +291,7 @@ func migrateV3ToV4() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv3.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version)
return nil
}
@ -332,7 +332,7 @@ func migrateV4ToV5() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv4.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version)
return nil
}
@ -421,7 +421,7 @@ func migrateV5ToV6() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv5.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version)
return nil
}
@ -477,7 +477,7 @@ func migrateV6ToV7() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv6.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version)
return nil
}
@ -540,7 +540,7 @@ func migrateV7ToV8() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv7.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version)
return nil
}
@ -610,7 +610,7 @@ func migrateV8ToV9() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv8.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version)
return nil
}
@ -678,7 +678,7 @@ func migrateV9ToV10() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv9.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version)
return nil
}
@ -749,7 +749,7 @@ func migrateV10ToV11() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv10.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version)
return nil
}
@ -847,7 +847,7 @@ func migrateV11ToV12() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv11.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version)
return nil
}
@ -927,7 +927,7 @@ func migrateV12ToV13() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv12.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version)
return nil
}
@ -1012,7 +1012,7 @@ func migrateV13ToV14() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv13.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version)
return nil
}
@ -1101,7 +1101,7 @@ func migrateV14ToV15() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv14.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version)
return nil
}
@ -1191,7 +1191,7 @@ func migrateV15ToV16() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv15.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version)
return nil
}
@ -1312,7 +1312,7 @@ func migrateV16ToV17() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv16.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version)
return nil
}
@ -1416,7 +1416,7 @@ func migrateV17ToV18() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv17.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version)
return nil
}
@ -1522,7 +1522,7 @@ func migrateV18ToV19() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv18.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version)
return nil
}
@ -1627,7 +1627,7 @@ func migrateV19ToV20() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv19.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version)
return nil
}
@ -1731,7 +1731,7 @@ func migrateV20ToV21() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv20.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version)
return nil
}
@ -1835,7 +1835,7 @@ func migrateV21ToV22() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv21.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version)
return nil
}
@ -1948,6 +1948,6 @@ func migrateV22ToV23() error {
return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv22.Version, srvConfig.Version, err)
}
logger.Printf(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version)
logger.Info(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version)
return nil
}

@ -209,7 +209,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
// Print a warning message if gateway is not ready for production before the startup banner.
if !gw.Production() {
logger.Println(colorYellow("\n *** Warning: Not Ready for Production ***"))
logger.StartupMessage(colorYellow("\n *** Warning: Not Ready for Production ***"))
}
// Print gateway startup message.

@ -56,12 +56,12 @@ func printGatewayCommonMsg(apiEndpoints []string) {
apiEndpointStr := strings.Join(apiEndpoints, " ")
// Colorize the message and print.
logger.Println(colorBlue("\nEndpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr)))
logger.Println(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKey)))
logger.Println(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretKey)))
logger.StartupMessage(colorBlue("\nEndpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr)))
logger.StartupMessage(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKey)))
logger.StartupMessage(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretKey)))
if globalIsBrowserEnabled {
logger.Println(colorBlue("\nBrowser Access:"))
logger.Println(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr))
logger.StartupMessage(colorBlue("\nBrowser Access:"))
logger.StartupMessage(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr))
}
}

@ -163,9 +163,9 @@ func (g *Sia) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
colorBlue := color.New(color.FgBlue).SprintfFunc()
colorBold := color.New(color.Bold).SprintFunc()
logger.Println(colorBlue("\nSia Gateway Configuration:"))
logger.Println(colorBlue(" Sia Daemon API Address:") + colorBold(fmt.Sprintf(" %s\n", sia.Address)))
logger.Println(colorBlue(" Sia Temp Directory:") + colorBold(fmt.Sprintf(" %s\n", sia.TempDir)))
logger.StartupMessage(colorBlue("\nSia Gateway Configuration:"))
logger.StartupMessage(colorBlue(" Sia Daemon API Address:") + colorBold(fmt.Sprintf(" %s\n", sia.Address)))
logger.StartupMessage(colorBlue(" Sia Temp Directory:") + colorBold(fmt.Sprintf(" %s\n", sia.TempDir)))
return sia, nil
}

@ -45,7 +45,8 @@ type Level int8
// Enumerated level types
const (
Error Level = iota + 1
Information Level = iota + 1
Error
Fatal
)
@ -61,6 +62,8 @@ var matchingFuncNames = [...]string{
func (level Level) String() string {
var lvlStr string
switch level {
case Information:
lvlStr = "INFO"
case Error:
lvlStr = "ERROR"
case Fatal:
@ -69,9 +72,26 @@ func (level Level) String() string {
return lvlStr
}
// Console interface describes the methods that needs to be implemented to satisfy the interface requirements.
type Console interface {
json(msg string, args ...interface{})
quiet(msg string, args ...interface{})
pretty(msg string, args ...interface{})
}
func consoleLog(console Console, msg string, args ...interface{}) {
if jsonFlag {
console.json(msg, args...)
} else if quiet {
console.quiet(msg, args...)
} else {
console.pretty(msg, args...)
}
}
type traceEntry struct {
Message string `json:"message"`
Source []string `json:"source"`
Message string `json:"message,omitempty"`
Source []string `json:"source,omitempty"`
Variables map[string]string `json:"variables,omitempty"`
}
type args struct {
@ -81,18 +101,18 @@ type args struct {
type api struct {
Name string `json:"name,omitempty"`
Args args `json:"args,omitempty"`
Args *args `json:"args,omitempty"`
}
type logEntry struct {
Level string `json:"level"`
Time string `json:"time"`
API api `json:"api,omitempty"`
API *api `json:"api,omitempty"`
RemoteHost string `json:"remotehost,omitempty"`
RequestID string `json:"requestID,omitempty"`
UserAgent string `json:"userAgent,omitempty"`
Cause string `json:"cause,omitempty"`
Trace traceEntry `json:"error"`
Message string `json:"message,omitempty"`
Trace *traceEntry `json:"error,omitempty"`
}
// quiet: Hide startup messages if enabled
@ -112,20 +132,6 @@ func EnableJSON() {
quiet = true
}
// Println - wrapper to console.Println() with quiet flag.
func Println(args ...interface{}) {
if !quiet {
console.Println(args...)
}
}
// Printf - wrapper to console.Printf() with quiet flag.
func Printf(format string, args ...interface{}) {
if !quiet {
console.Printf(format, args...)
}
}
// Init sets the trimStrings to possible GOPATHs
// and GOROOT directories. Also append github.com/minio/minio
// This is done to clean up the filename, when stack trace is
@ -171,6 +177,17 @@ func trimTrace(f string) string {
return filepath.FromSlash(f)
}
func getSource() string {
pc, file, lineNumber, ok := runtime.Caller(5)
if ok {
// Clean up the common prefixes
file = trimTrace(file)
_, funcName := filepath.Split(runtime.FuncForPC(pc).Name())
return fmt.Sprintf("%v:%v:%v()", file, lineNumber, funcName)
}
return ""
}
// getTrace method - creates and returns stack trace
func getTrace(traceLevel int) []string {
var trace []string
@ -203,57 +220,6 @@ func getTrace(traceLevel int) []string {
return trace
}
func logIf(level Level, err error, msg string,
data ...interface{}) {
if err == nil {
return
}
// Get the cause for the Error
cause := err.Error()
// Get full stack trace
trace := getTrace(3)
// Get time
timeOfError := time.Now().UTC().Format(time.RFC3339Nano)
// Output the formatted log message at console
var output string
message := fmt.Sprintf(msg, data...)
if jsonFlag {
logJSON, err := json.Marshal(&logEntry{
Level: level.String(),
Time: timeOfError,
Cause: cause,
Trace: traceEntry{Source: trace, Message: message},
})
if err != nil {
panic("json marshal of logEntry failed: " + err.Error())
}
output = string(logJSON)
} else {
// Add a sequence number and formatting for each stack trace
// No formatting is required for the first entry
trace[0] = "1: " + trace[0]
for i, element := range trace[1:] {
trace[i+1] = fmt.Sprintf("%8v: %s", i+2, element)
}
errMsg := fmt.Sprintf("[%s] [%s] %s (%s)",
timeOfError, level.String(), message, cause)
output = fmt.Sprintf("\nTrace: %s\n%s",
strings.Join(trace, "\n"),
colorRed(colorBold(errMsg)))
}
fmt.Println(output)
if level == Fatal {
os.Exit(1)
}
}
// FatalIf :
func FatalIf(err error, msg string, data ...interface{}) {
logIf(Fatal, err, msg, data...)
}
// LogIf :
func LogIf(ctx context.Context, err error) {
if err == nil {
@ -289,8 +255,8 @@ func LogIf(ctx context.Context, err error) {
RequestID: req.RequestID,
UserAgent: req.UserAgent,
Time: time.Now().UTC().Format(time.RFC3339Nano),
API: api{Name: API, Args: args{Bucket: req.BucketName, Object: req.ObjectName}},
Trace: traceEntry{Message: message, Source: trace, Variables: tags},
API: &api{Name: API, Args: &args{Bucket: req.BucketName, Object: req.ObjectName}},
Trace: &traceEntry{Message: message, Source: trace, Variables: tags},
})
if err != nil {
panic(err)
@ -348,3 +314,93 @@ func LogIf(ctx context.Context, err error) {
}
fmt.Println(output)
}
// FatalIf :
func FatalIf(err error, msg string, data ...interface{}) {
if err != nil {
if msg != "" {
consoleLog(fatalMessage, msg, data...)
} else {
consoleLog(fatalMessage, err.Error())
}
}
}
var fatalMessage fatalMsg
type fatalMsg struct {
}
func (f fatalMsg) json(msg string, args ...interface{}) {
logJSON, err := json.Marshal(&logEntry{
Level: Fatal.String(),
Time: time.Now().UTC().Format(time.RFC3339Nano),
Trace: &traceEntry{Message: fmt.Sprintf(msg, args...), Source: []string{getSource()}},
})
if err != nil {
panic(err)
}
fmt.Println(string(logJSON))
os.Exit(1)
}
func (f fatalMsg) quiet(msg string, args ...interface{}) {
f.pretty(msg, args...)
}
func (f fatalMsg) pretty(msg string, args ...interface{}) {
errMsg := fmt.Sprintf(msg, args...)
fmt.Println(colorRed(colorBold("Error: " + errMsg)))
os.Exit(1)
}
var info infoMsg
type infoMsg struct {
}
func (i infoMsg) json(msg string, args ...interface{}) {
logJSON, err := json.Marshal(&logEntry{
Level: Information.String(),
Message: fmt.Sprintf(msg, args...),
Time: time.Now().UTC().Format(time.RFC3339Nano),
})
if err != nil {
panic(err)
}
fmt.Println(string(logJSON))
}
func (i infoMsg) quiet(msg string, args ...interface{}) {
i.pretty(msg, args...)
}
func (i infoMsg) pretty(msg string, args ...interface{}) {
console.Printf(msg, args...)
}
// Info :
func Info(msg string, data ...interface{}) {
consoleLog(info, msg+"\n", 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{}) {
console.Printf(msg, args...)
}
// StartupMessage :
func StartupMessage(msg string, data ...interface{}) {
consoleLog(startupMessage, msg+"\n", data...)
}

@ -22,7 +22,6 @@ import (
"os"
"time"
"github.com/minio/mc/pkg/console"
"github.com/minio/minio/cmd/logger"
)
@ -218,11 +217,11 @@ func waitForFormatXL(ctx context.Context, firstDisk bool, endpoints EndpointList
switch err {
case errNotFirstDisk:
// Fresh setup, wait for first server to be up.
console.Println("Waiting for the first server to format the disks.")
logger.Info("Waiting for the first server to format the disks.")
continue
case errXLReadQuorum:
// no quorum available continue to wait for minimum number of servers.
console.Printf("Waiting for a minimum of %d disks to come online (elapsed %s)\n", len(endpoints)/2, getElapsedTime())
logger.Info("Waiting for a minimum of %d disks to come online (elapsed %s)\n", len(endpoints)/2, getElapsedTime())
continue
case errXLV3ThisEmpty:
// need to wait for this error to be healed, so continue.

@ -115,17 +115,17 @@ func printServerCommonMsg(apiEndpoints []string) {
apiEndpointStr := strings.Join(apiEndpoints, " ")
// Colorize the message and print.
logger.Println(colorBlue("Endpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr)))
logger.Println(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKey)))
logger.Println(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretKey)))
logger.StartupMessage(colorBlue("Endpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr)))
logger.StartupMessage(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKey)))
logger.StartupMessage(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretKey)))
if region != "" {
logger.Println(colorBlue("Region: ") + colorBold(fmt.Sprintf(getFormatStr(len(region), 3), region)))
logger.StartupMessage(colorBlue("Region: ") + colorBold(fmt.Sprintf(getFormatStr(len(region), 3), region)))
}
printEventNotifiers()
if globalIsBrowserEnabled {
logger.Println(colorBlue("\nBrowser Access:"))
logger.Println(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr))
logger.StartupMessage(colorBlue("\nBrowser Access:"))
logger.StartupMessage(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr))
}
}
@ -141,7 +141,7 @@ func printEventNotifiers() {
arnMsg += colorBold(fmt.Sprintf(getFormatStr(len(arn), 1), arn))
}
logger.Println(arnMsg)
logger.StartupMessage(arnMsg)
}
// Prints startup message for command line access. Prints link to our documentation
@ -151,24 +151,24 @@ func printCLIAccessMsg(endPoint string, alias string) {
cred := globalServerConfig.GetCredential()
// Configure 'mc', following block prints platform specific information for minio client.
logger.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
logger.StartupMessage(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
if runtime.GOOS == globalWindowsOSName {
mcMessage := fmt.Sprintf("$ mc.exe config host add %s %s %s %s", alias, endPoint, cred.AccessKey, cred.SecretKey)
logger.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
logger.StartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
} else {
mcMessage := fmt.Sprintf("$ mc config host add %s %s %s %s", alias, endPoint, cred.AccessKey, cred.SecretKey)
logger.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
logger.StartupMessage(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
}
}
// Prints startup message for Object API acces, prints link to our SDK documentation.
func printObjectAPIMsg() {
logger.Println(colorBlue("\nObject API (Amazon S3 compatible):"))
logger.Println(colorBlue(" Go: ") + fmt.Sprintf(getFormatStr(len(goQuickStartGuide), 8), goQuickStartGuide))
logger.Println(colorBlue(" Java: ") + fmt.Sprintf(getFormatStr(len(javaQuickStartGuide), 6), javaQuickStartGuide))
logger.Println(colorBlue(" Python: ") + fmt.Sprintf(getFormatStr(len(pyQuickStartGuide), 4), pyQuickStartGuide))
logger.Println(colorBlue(" JavaScript: ") + jsQuickStartGuide)
logger.Println(colorBlue(" .NET: ") + fmt.Sprintf(getFormatStr(len(dotnetQuickStartGuide), 6), dotnetQuickStartGuide))
logger.StartupMessage(colorBlue("\nObject API (Amazon S3 compatible):"))
logger.StartupMessage(colorBlue(" Go: ") + fmt.Sprintf(getFormatStr(len(goQuickStartGuide), 8), goQuickStartGuide))
logger.StartupMessage(colorBlue(" Java: ") + fmt.Sprintf(getFormatStr(len(javaQuickStartGuide), 6), javaQuickStartGuide))
logger.StartupMessage(colorBlue(" Python: ") + fmt.Sprintf(getFormatStr(len(pyQuickStartGuide), 4), pyQuickStartGuide))
logger.StartupMessage(colorBlue(" JavaScript: ") + jsQuickStartGuide)
logger.StartupMessage(colorBlue(" .NET: ") + fmt.Sprintf(getFormatStr(len(dotnetQuickStartGuide), 6), dotnetQuickStartGuide))
}
// Get formatted disk/storage info message.
@ -185,15 +185,14 @@ func getStorageInfoMsg(storageInfo StorageInfo) string {
// Prints startup message of storage capacity and erasure information.
func printStorageInfo(storageInfo StorageInfo) {
logger.Println(getStorageInfoMsg(storageInfo))
logger.Println()
logger.StartupMessage(getStorageInfoMsg(storageInfo) + "\n")
}
func printCacheStorageInfo(storageInfo StorageInfo) {
msg := fmt.Sprintf("%s %s Free, %s Total", colorBlue("Cache Capacity:"),
humanize.IBytes(uint64(storageInfo.Free)),
humanize.IBytes(uint64(storageInfo.Total)))
logger.Println(msg)
logger.StartupMessage(msg)
}
// Prints certificate expiry date warning
@ -216,5 +215,5 @@ func getCertificateChainMsg(certs []*x509.Certificate) string {
// Prints the certificate expiry message.
func printCertificateMsg(certs []*x509.Certificate) {
logger.Println(getCertificateChainMsg(certs))
logger.StartupMessage(getCertificateChainMsg(certs))
}

@ -68,14 +68,14 @@ func handleSignals() {
exit(err == nil && oerr == nil)
case osSignal := <-globalOSSignalCh:
stopHTTPTrace()
logger.Printf("Exiting on signal %v\n", osSignal)
logger.Info("Exiting on signal %v", osSignal)
exit(stopProcess())
case signal := <-globalServiceSignalCh:
switch signal {
case serviceStatus:
// Ignore this at the moment.
case serviceRestart:
logger.Println("Restarting on service signal")
logger.Info("Restarting on service signal")
err := globalHTTPServer.Shutdown()
logger.LogIf(context.Background(), err)
stopHTTPTrace()
@ -84,7 +84,7 @@ func handleSignals() {
exit(err == nil && rerr == nil)
case serviceStop:
logger.Println("Stopping on service signal")
logger.Info("Stopping on service signal")
stopHTTPTrace()
exit(stopProcess())
}

@ -501,27 +501,27 @@ func mainUpdate(ctx *cli.Context) {
minioMode := ""
updateMsg, sha256Hex, _, latestReleaseTime, err := getUpdateInfo(10*time.Second, minioMode)
if err != nil {
logger.Println(err)
logger.Info(err.Error())
os.Exit(-1)
}
// Nothing to update running the latest release.
if updateMsg == "" {
logger.Println(greenColorSprintf("You are already running the most recent version of ‘minio’."))
logger.Info(greenColorSprintf("You are already running the most recent version of ‘minio’."))
os.Exit(0)
}
logger.Println(updateMsg)
logger.Info(updateMsg)
// if the in-place update is disabled then we shouldn't ask the
// user to update the binaries.
if strings.Contains(updateMsg, minioReleaseURL) && !globalInplaceUpdateDisabled {
var successMsg string
successMsg, err = doUpdate(sha256Hex, latestReleaseTime, shouldUpdate(quiet, sha256Hex, latestReleaseTime))
if err != nil {
logger.Println(err)
logger.Info(err.Error())
os.Exit(-1)
}
logger.Println(successMsg)
logger.Info(successMsg)
os.Exit(1)
}
}

Loading…
Cancel
Save