Include log level option
This commit is contained in:
parent
22c0580cc7
commit
099f2ae41a
@ -942,6 +942,7 @@ There is the most valuable changes log:
|
||||
2. Build and test on go 1.12
|
||||
3. Support `--color` option
|
||||
4. Update x/tools to fix c++ issues
|
||||
5. Include support to log level
|
||||
|
||||
### February 2019
|
||||
|
||||
|
@ -491,6 +491,7 @@ There is the most valuable changes log:
|
||||
2. Build and test on go 1.12
|
||||
3. Support `--color` option
|
||||
4. Update x/tools to fix c++ issues
|
||||
5. Include support to log level
|
||||
|
||||
### February 2019
|
||||
|
||||
|
@ -24,12 +24,22 @@ func NewStderrLog(name string) *StderrLog {
|
||||
level: LogLevelWarn,
|
||||
}
|
||||
|
||||
// control log level in logutils, not in logrus
|
||||
sl.logger.SetLevel(logrus.DebugLevel)
|
||||
switch os.Getenv("LOG_LEVEL") {
|
||||
case "error", "err":
|
||||
sl.logger.SetLevel(logrus.ErrorLevel)
|
||||
case "warning", "warn":
|
||||
sl.logger.SetLevel(logrus.WarnLevel)
|
||||
case "info":
|
||||
sl.logger.SetLevel(logrus.InfoLevel)
|
||||
default:
|
||||
sl.logger.SetLevel(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
sl.logger.Out = StdErr
|
||||
sl.logger.Formatter = &logrus.TextFormatter{
|
||||
DisableTimestamp: true, // `INFO[0007] msg` -> `INFO msg`
|
||||
}
|
||||
|
||||
return sl
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user