mirror of
https://github.com/go-gost/x.git
synced 2026-10-19 16:16:32 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user