config/parsing/logger: say when a log file has no rotation

A configured output path without a rotation block is a plain file that nothing
rotates: it grows until the disk does something about it. The default logger —
the one an unconfigured program gets — always carries a rotation, so this only
happens to a hand-written config, and the parser is the only place that sees
both the path and the rotation that is missing. Reported on stderr, once, at
parse time; nothing about the behaviour changes.
This commit is contained in:
ginuerzh
2026-09-29 16:18:39 +08:00
parent 1fadb8fe38
commit ec4800293d
+4
View File
@@ -45,6 +45,10 @@ func ParseLogger(cfg *config.LoggerConfig) logger.Logger {
Compress: cfg.Log.Rotation.Compress,
}
} else {
// Nothing rotates this file, and it is the only place that sees both
// the path and the missing rotation — the default (an unconfigured
// logger) always carries one.
fmt.Fprintf(os.Stderr, "logger: %s has no rotation configured: it will grow without bound\n", cfg.Log.Output)
os.MkdirAll(filepath.Dir(cfg.Log.Output), 0755)
f, err := os.OpenFile(cfg.Log.Output, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {