MCPcopy Index your code
hub / github.com/codehamr/codehamr / OpenDebugLog

Function OpenDebugLog

internal/tui/debuglog.go:30–44  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

28// can carry secrets even past the slash redaction below. Owner-only is the
29// only honest answer.
30func 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.
47func CloseDebugLog() {

Callers 4

mainFunction · 0.92
TestCtxPressureTripwireFunction · 0.85

Calls 1

dbgWritefFunction · 0.85