Skip to content

Commit

Permalink
[logutil]: Fix MaxDays and MaxBackups not working for slow-query-…
Browse files Browse the repository at this point in the history
…logger (#27625) (#30171)

ref #25716
  • Loading branch information
ti-srebot committed Feb 9, 2022
1 parent be7a95d commit 51f6ed9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions util/logutil/slow_query_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ var _pool = buffer.NewPool()

func newSlowQueryLogger(cfg *LogConfig) (*zap.Logger, *log.ZapProperties, error) {

// copy global config and override slow query log file
// if slow query log filename is empty, slow query log will behave the same as global log
// copy the global log config to slow log config
// if the filename of slow log config is empty, slow log will behave the same as global log.
sqConfig := cfg.Config
// level of the global log config doesn't affect the slow query logger which determines whether to
// log by execution duration.
sqConfig.Level = LogConfig{}.Level
if len(cfg.SlowQueryFile) != 0 {
sqConfig.File = log.FileLogConfig{
MaxSize: cfg.File.MaxSize,
Filename: cfg.SlowQueryFile,
}
sqConfig.File = cfg.File
sqConfig.File.Filename = cfg.SlowQueryFile
}

// create the slow query logger
Expand Down

0 comments on commit 51f6ed9

Please sign in to comment.