mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
Write all logging (INFO, WARN, ERROR) to stderr
The old setup tried to log >= warning to stderr, the rest to stdout. However, that logic was flawed, so warnings ended up in stdout, which makes `hugo list all` etc. hard to reason about from scripts. This commit fixes this by making all logging (info, warn, error) log to stderr and let stdout be reserved for program output. Fixes #13074
This commit is contained in:
committed by
GitHub
parent
ec1933f79d
commit
9dfa112617
@@ -145,8 +145,11 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
|
||||
if cfg.Configs.Base.PanicOnWarning {
|
||||
logHookLast = loggers.PanicOnWarningHook
|
||||
}
|
||||
if cfg.LogOut == nil {
|
||||
cfg.LogOut = os.Stdout
|
||||
if cfg.StdOut == nil {
|
||||
cfg.StdOut = os.Stdout
|
||||
}
|
||||
if cfg.StdErr == nil {
|
||||
cfg.StdErr = os.Stderr
|
||||
}
|
||||
if cfg.LogLevel == 0 {
|
||||
cfg.LogLevel = logg.LevelWarn
|
||||
@@ -156,8 +159,8 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
|
||||
Level: cfg.LogLevel,
|
||||
DistinctLevel: logg.LevelWarn, // This will drop duplicate log warning and errors.
|
||||
HandlerPost: logHookLast,
|
||||
Stdout: cfg.LogOut,
|
||||
Stderr: cfg.LogOut,
|
||||
StdOut: cfg.StdOut,
|
||||
StdErr: cfg.StdErr,
|
||||
StoreErrors: conf.Watching(),
|
||||
SuppressStatements: conf.IgnoredLogs(),
|
||||
}
|
||||
|
Reference in New Issue
Block a user