Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[logutil]: Fix MaxDays and MaxBackups not working for slow-query-logger #27625

Merged
merged 8 commits into from
Nov 18, 2021
10 changes: 4 additions & 6 deletions util/logutil/slow_query_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ 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
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