diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 68a93f540b..c782abd0f0 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -116,7 +116,14 @@ func Setup(ctx *cli.Context, disklogs string) error { // logging log.PrintOrigins(ctx.GlobalBool(debugFlag.Name)) if disklogs != "" { - glogger.SetHandler(log.MultiHandler(ostream, log.RotatingFileHandler(disklogs, 262144))) + glogger.SetHandler(log.MultiHandler( + ostream, + log.RotatingFileHandler( + disklogs, + 262144, + log.JsonFormatOrderedCtx(false, true), + ), + )) } glogger.Verbosity(log.Lvl(ctx.GlobalInt(verbosityFlag.Name))) glogger.Vmodule(ctx.GlobalString(vmoduleFlag.Name)) diff --git a/log/handler.go b/log/handler.go index cb90f0bf7e..7879be9947 100644 --- a/log/handler.go +++ b/log/handler.go @@ -88,7 +88,7 @@ func (w *writeCounter) Write(p []byte) (n int, err error) { // RotatingFileHandler returns a handler which writes log records to file chunks // at the given path. When a file's size reaches the limit, the handler creates // a new file named after the timestamp of the first log record it will contain. -func RotatingFileHandler(path string, limit uint) Handler { +func RotatingFileHandler(path string, limit uint, formatter Format) Handler { if err := os.MkdirAll(path, 0755); err != nil { panic(err) } @@ -98,7 +98,7 @@ func RotatingFileHandler(path string, limit uint) Handler { panic(err) } counter := new(writeCounter) - h := StreamHandler(counter, JsonFormatOrderedCtx(false, true)) + h := StreamHandler(counter, formatter) re := regexp.MustCompile(".log$") var i int