{"id":"28a3134f4edb15b3","repo":"gohugoio/hugo","slug":"invalid-log-level-q-must-be-one-of-debug-warn","errorCode":null,"errorMessage":"invalid log level: %q, must be one of debug, warn, info or error","messagePattern":"invalid log level: %q, must be one of debug, warn, info or error","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/commandeer.go","lineNumber":509,"sourceCode":"\nfunc (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {\n\tlevel := logg.LevelWarn\n\n\tif r.devMode {\n\t\tlevel = logg.LevelTrace\n\t} else {\n\t\tif r.logLevel != \"\" {\n\t\t\tswitch strings.ToLower(r.logLevel) {\n\t\t\tcase \"debug\":\n\t\t\t\tlevel = logg.LevelDebug\n\t\t\tcase \"info\":\n\t\t\t\tlevel = logg.LevelInfo\n\t\t\tcase \"warn\", \"warning\":\n\t\t\t\tlevel = logg.LevelWarn\n\t\t\tcase \"error\":\n\t\t\t\tlevel = logg.LevelError\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"invalid log level: %q, must be one of debug, warn, info or error\", r.logLevel)\n\t\t\t}\n\t\t}\n\t}\n\n\tvar logHookLast func(e *logg.Entry) error\n\tif r.panicOnWarning {\n\t\tlogHookLast = loggers.PanicOnWarningHook\n\t}\n\n\toptsLogger := loggers.Options{\n\t\tDistinctLevel: logg.LevelWarn,\n\t\tLevel:         level,\n\t\tStdOut:        r.StdOut,\n\t\tStdErr:        r.StdErr,\n\t\tStoreErrors:   running,\n\t\tHandlerPost:   logHookLast,\n\t}\n","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/commandeer.go#L491-L527","documentation":"Emitted while building the logger when the `--logLevel` flag value doesn't match one of the accepted names. Hugo lowercases the value and accepts only `debug`, `info`, `warn`/`warning`, and `error`; anything else aborts startup so a typo can't silently run with the wrong verbosity. Note `--logLevel` is ignored entirely in dev mode, which forces trace.","triggerScenarios":"Any Hugo invocation with `--logLevel <value>` where the lowercased value isn't debug/info/warn/warning/error — e.g. `--logLevel verbose`, `--logLevel trace`, `--logLevel DEBUG2`.","commonSituations":"Muscle memory from other tools using `trace`, `fatal`, or `verbose` levels; scripts written for the pre-0.114 `--verbose`/`--debug` flags migrated incorrectly; env-driven CI variables containing stray whitespace or wrong values.","solutions":["Change the flag to one of the accepted values: `--logLevel info` (or debug, warn, error).","If you wanted trace-level output, there is no public trace level — use `--logLevel debug`.","In scripts, replace removed `--verbose`/`--debug` flags with `--logLevel info`/`--logLevel debug`."],"exampleFix":"# before\nhugo --logLevel verbose\n# after\nhugo --logLevel info","handlingStrategy":"validation","validationCode":"validLevels := map[string]bool{\"debug\": true, \"info\": true, \"warn\": true, \"error\": true}\nif !validLevels[strings.ToLower(level)] {\n    return fmt.Errorf(\"invalid --logLevel %q; use debug|info|warn|error\", level)\n}","typeGuard":"func isValidLogLevel(s string) bool {\n    switch strings.ToLower(s) {\n    case \"debug\", \"info\", \"warn\", \"error\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Validate CLI flags against the enumerated set before invoking hugo","Don't pass legacy values like \"trace\" or \"warning\"; map them to the supported four","Centralize the allowed-levels list so scripts and docs stay in sync"],"tags":["hugo","cli","logging","flags"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}