From 025cdd66c5788e5064b482b2d77f79054745ff69 Mon Sep 17 00:00:00 2001 From: John Guo Date: Sat, 26 Jun 2021 11:25:54 +0800 Subject: [PATCH] improve details for package glog --- os/glog/glog_logger_config.go | 5 ++--- os/glog/glog_logger_level.go | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/os/glog/glog_logger_config.go b/os/glog/glog_logger_config.go index a08275c1d..709a7976c 100644 --- a/os/glog/glog_logger_config.go +++ b/os/glog/glog_logger_config.go @@ -41,7 +41,7 @@ type Config struct { RotateBackupLimit int `json:"rotateBackupLimit"` // Max backup for rotated files, default is 0, means no backups. RotateBackupExpire time.Duration `json:"rotateBackupExpire"` // Max expire for rotated files, which is 0 in default, means no expiration. RotateBackupCompress int `json:"rotateBackupCompress"` // Compress level for rotated files using gzip algorithm. It's 0 in default, means no compression. - RotateCheckInterval time.Duration `json:"rotateCheckInterval"` // Asynchronizely checks the backups and expiration at intervals. It's 1 hour in default. + RotateCheckInterval time.Duration `json:"rotateCheckInterval"` // Asynchronous checks the backups and expiration at intervals. It's 1 hour in default. } // DefaultConfig returns the default configuration for logger. @@ -104,8 +104,7 @@ func (l *Logger) SetConfigWithMap(m map[string]interface{}) error { return errors.New(fmt.Sprintf(`invalid rotate size: %v`, rotateSizeValue)) } } - err := gconv.Struct(m, &l.config) - if err != nil { + if err := gconv.Struct(m, &l.config); err != nil { return err } return l.SetConfig(l.config) diff --git a/os/glog/glog_logger_level.go b/os/glog/glog_logger_level.go index a756bc6f8..fe1cfdb4e 100644 --- a/os/glog/glog_logger_level.go +++ b/os/glog/glog_logger_level.go @@ -62,8 +62,10 @@ var levelStringMap = map[string]int{ } // SetLevel sets the logging level. +// Note that levels ` LEVEL_CRIT | LEVEL_PANI | LEVEL_FATA ` cannot be removed for logging content, +// which are automatically added to levels. func (l *Logger) SetLevel(level int) { - l.config.Level = level + l.config.Level = level | LEVEL_CRIT | LEVEL_PANI | LEVEL_FATA } // GetLevel returns the logging level value.