{"record":{"id":"424e28c3ea6ff476","repo":"vitessio/vitess","slug":"log-invalid-log-level-q-w","errorCode":null,"errorMessage":"log: invalid --log-level %q: %w","messagePattern":"log: invalid --log-level %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/log/flags.go","lineNumber":73,"sourceCode":"func Init(fs *pflag.FlagSet) error {\n\tif !logStructured {\n\t\tfmt.Fprintln(os.Stderr, \"WARNING: glog is deprecated and will be removed in v25\")\n\t\tstructured.Store(false)\n\t\treturn nil\n\t}\n\n\t// Warn if any glog flags were explicitly set while structured logging is active,\n\t// since they have no effect.\n\tfor _, name := range []string{\"logtostderr\", \"alsologtostderr\", \"stderrthreshold\", \"log_dir\", \"log_backtrace_at\", \"vmodule\", \"v\"} {\n\t\tif fs.Changed(name) {\n\t\t\tfmt.Fprintf(os.Stderr, \"WARNING: --%s has no effect when structured logging is enabled, pass --log-structured=false to use glog flags\\n\", name)\n\t\t}\n\t}\n\n\t// Parse the level flag into an [slog.Level].\n\tvar level slog.Level\n\tif err := level.UnmarshalText([]byte(logLevel)); err != nil {\n\t\treturn fmt.Errorf(\"log: invalid --log-level %q: %w\", logLevel, err)\n\t}\n\n\tl := newLogger(level)\n\tlogger.Store(l)\n\tstructured.Store(true)\n\n\treturn nil\n}\n\n// newLogger creates a new structured logger. When the log format is \"text\", or we detect\n// we're running tests, logs are outputted in a human-readable format (and optionally colored).\n// Otherwise, or when the log format is \"json\", logs are outputted as machine-readable JSON.\nfunc newLogger(level slog.Level) *slog.Logger {\n\tif logFormat == \"text\" || testing.Testing() {\n\t\tw := os.Stderr\n\t\treturn slog.New(tint.NewTextHandler(w, &tint.Options{\n\t\t\tAddSource:  true,\n\t\t\tLevel:      level,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/log/flags.go#L55-L91","documentation":"log.Init parses the --log-level flag into an slog.Level using UnmarshalText, which accepts values like DEBUG, INFO, WARN, ERROR (case-insensitive). The library wraps the parse failure with this message when the supplied level string is not a recognized slog level.","triggerScenarios":"Running any Vitess binary with --log-level set to an unsupported value, e.g. --log-level=verbose, --log-level=trace, --log-level=3 (numeric text is not valid here), or an empty string.","commonSituations":"Users copying log level names from other frameworks (e.g. 'warning' vs 'warn', 'trace'), old glog-style flags (-v=2) translated incorrectly to the new --log-level flag, typos in service startup scripts or systemd units.","solutions":["Use a valid slog level: DEBUG, INFO, WARN or ERROR (case-insensitive), e.g. --log-level=INFO.","Replace legacy numeric verbosity (-v=2) with the matching named level.","Check the exact error's wrapped text (the %w) to see which character/value UnmarshalText rejected."],"exampleFix":"// before\nvttablet --log-level=trace\n// after\nvttablet --log-level=DEBUG","handlingStrategy":"validation","validationCode":"var lvl slog.Level\nif err := lvl.UnmarshalText([]byte(logLevel)); err != nil {\n\treturn fmt.Errorf(\"--log-level must be one of DEBUG|INFO|WARN|ERROR\")\n}","typeGuard":null,"tryCatchPattern":"if err := log.Init(ctx, \"vttablet\"); err != nil {\n\treturn fmt.Errorf(\"logging init failed: %w\", err)\n}","preventionTips":["Use only DEBUG, INFO, WARN, ERROR (case-insensitive) for --log-level","Translate legacy glog -v numerics to named levels","Test service startup scripts after changing log flags"],"tags":["go","logging","cli-flags","input-validation"],"backgroundTag":"invalid-log-level","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}