{"record":{"id":"89e0e0d0e1d6551c","repo":"txthinking/brook","slug":"log-must-be-with-absolute-path","errorCode":null,"errorMessage":"--log must be with absolute path","messagePattern":"--log must be with absolute path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/brook/main.go","lineNumber":191,"sourceCode":"\t\t\t}\n\t\t}\n\t\tif c.String(\"pprof\") != \"\" {\n\t\t\tp, err := pprof.NewPprof(c.String(\"pprof\"))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tg.Add(&runnergroup.Runner{\n\t\t\t\tStart: func() error {\n\t\t\t\t\treturn p.ListenAndServe()\n\t\t\t\t},\n\t\t\t\tStop: func() error {\n\t\t\t\t\treturn p.Shutdown()\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif c.String(\"log\") != \"\" {\n\t\t\tif c.String(\"log\") != \"console\" && !filepath.IsAbs(c.String(\"log\")) {\n\t\t\t\treturn errors.New(\"--log must be with absolute path\")\n\t\t\t}\n\t\t\tvar m map[string]string\n\t\t\tif len(c.StringSlice(\"tag\")) > 0 {\n\t\t\t\tm = make(map[string]string)\n\t\t\t\tfor _, v := range c.StringSlice(\"tag\") {\n\t\t\t\t\tl := strings.Split(v, \":\")\n\t\t\t\t\tif len(l) != 2 {\n\t\t\t\t\t\treturn errors.New(\"Invalid tag \" + v)\n\t\t\t\t\t}\n\t\t\t\t\tm[l[0]] = l[1]\n\t\t\t\t}\n\t\t\t}\n\t\t\tp, err := logger.NewLogger(m, c.String(\"log\"))\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tp.TouchBrook()\n\t\t\tf := df","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/txthinking/brook/blob/5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8/cli/brook/main.go#L173-L209","documentation":"The CLI validates --log in app.Before: the value must be either the literal \"console\" or an absolute file path. Anything else (relative path) is rejected so log output location is deterministic. Execution aborts before the subcommand runs.","triggerScenarios":"Running any brook subcommand with --log brook.log or --log ./logs/brook.log (relative path), i.e. neither \"console\" nor an absolute path.","commonSituations":"Relative log paths in example configs; container images where the working directory changes; operators intending console output but passing a filename.","solutions":["Use an absolute path: --log /var/log/brook.log","Use --log console to log to stdout/stderr instead of a file","Convert the path to absolute in the wrapper script: --log \"$PWD/brook.log\""],"exampleFix":"// before\nbrook server -l :9999 --log logs/brook.log\n// after\nbrook server -l :9999 --log /var/log/brook.log","handlingStrategy":"validation","validationCode":"if logPath != \"\" && logPath != \"console\" && !filepath.IsAbs(logPath) {\n\treturn fmt.Errorf(\"--log must be \"console\" or absolute, got %q\", logPath)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use \"console\" for stdout/stderr logging in containers","Use absolute log paths elsewhere","Centralize flag values in a service template with absolute defaults"],"tags":["cli","logging","path-validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"5cd13ef3b1fb574e88ebf2c1b5d95f2ebe1342c8","analyzedAt":"2026-09-06T04:35:00.432Z","contentChangedAt":"2026-09-06T04:35:00.432Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}