OpenDebugLog truncates /log.txt and opens it for writing. On failure it reports once on stderr and disables logging: the log must never block the TUI from starting. 0o600 because the log captures every prompt: /hamrpass and bash args can carry secrets even past the slash redaction below.
(dir string)
| 28 | // can carry secrets even past the slash redaction below. Owner-only is the |
| 29 | // only honest answer. |
| 30 | func OpenDebugLog(dir string) { |
| 31 | if dir == "" { |
| 32 | return |
| 33 | } |
| 34 | path := filepath.Join(dir, "log.txt") |
| 35 | f, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o600) |
| 36 | if err != nil { |
| 37 | fmt.Fprintln(os.Stderr, "⚠ debuglog:", err) |
| 38 | return |
| 39 | } |
| 40 | dbgMu.Lock() |
| 41 | dbgFile = f |
| 42 | dbgMu.Unlock() |
| 43 | dbgWritef("session", "codehamr started · project=%s", dir) |
| 44 | } |
| 45 | |
| 46 | // CloseDebugLog flushes and closes the log. Idempotent. |
| 47 | func CloseDebugLog() { |