mirror of
https://github.com/minio/minio.git
synced 2025-12-08 08:42:43 -05:00
logger: Disassociate shared log config between console, file and syslog (#3333)
logurs is not helping us to set different log formats (json/text) to different loggers. Now, we create different logurs instances and call them in errorIf and fatalIf
This commit is contained in:
committed by
Harshavardhana
parent
01ae5bb39c
commit
22c98d3fa2
@@ -16,11 +16,7 @@
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
import "github.com/Sirupsen/logrus"
|
||||
|
||||
// consoleLogger - default logger if not other logging is enabled.
|
||||
type consoleLogger struct {
|
||||
@@ -32,15 +28,19 @@ type consoleLogger struct {
|
||||
func enableConsoleLogger() {
|
||||
clogger := serverConfig.GetConsoleLogger()
|
||||
if !clogger.Enable {
|
||||
// Disable console logger if asked for.
|
||||
log.Out = ioutil.Discard
|
||||
return
|
||||
}
|
||||
|
||||
consoleLogger := logrus.New()
|
||||
|
||||
// log.Out and log.Formatter use the default versions.
|
||||
// Only set specific log level.
|
||||
lvl, err := logrus.ParseLevel(clogger.Level)
|
||||
fatalIf(err, "Unknown log level found in the config file.")
|
||||
|
||||
log.Level = lvl
|
||||
consoleLogger.Level = lvl
|
||||
consoleLogger.Formatter = new(logrus.TextFormatter)
|
||||
log.mu.Lock()
|
||||
log.loggers = append(log.loggers, consoleLogger)
|
||||
log.mu.Unlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user