{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/commandeer.go#L491-L527","documentation":"The --logLevel flag accepts exactly four values: debug, info, warn (or warning), and error (commandeer.go:499-510). Any other string causes createLogger to return this error before the build starts. In devMode (--devMode) the level is forced to trace and this check is bypassed.","triggerScenarios":"Passing --logLevel trace, --logLevel verbose, --logLevel fatal, or any value outside the allowed set.","commonSituations":"Assuming 'trace' or 'verbose' are valid log levels; typos like 'warng'; migrating from another tool's log-level vocabulary.","solutions":["Use one of: debug, info, warn, error (warning is also accepted)","Double-check the spelling of the flag value","Omit --logLevel to use the default (warn)"],"exampleFix":"# before\nhugo --logLevel trace\n# after\nhugo --logLevel debug","handlingStrategy":"validation","validationCode":"// Validate the log level string before passing it to Hugo.\nvar validLogLevels = map[string]bool{\"debug\": true, \"info\": true, \"warn\": true, \"warning\": true, \"error\": true}\nfunc validateLogLevel(level string) error {\n    if level == \"\" {\n        return nil\n    }\n    if !validLogLevels[strings.ToLower(level)] {\n        return fmt.Errorf(\"invalid log level: %q\", level)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only debug, info, warn, or error for --logLevel","Omit --logLevel to keep the default (warn)","Add shell completion for the flag using cobra's registered completions"],"tags":["cli","logging","config","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}