improve details for package glog

This commit is contained in:
John Guo
2021-06-26 11:25:54 +08:00
parent 237f172ae5
commit 025cdd66c5
2 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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.