Commit 19fc7f8
Luigi
refactor: harden log package for PR#102 review fixes
- Replace bare pointer with atomic.Pointer[slog.Logger] for safe concurrent SetLevel
- Move os.Getenv out of log.go into config.Config (LogFormat, LogLevel, LogSource)
to satisfy getenv audit invariant
- Add Configure(format, level, addSource) hook wired to cmd/api, worker, migrate
- TTY auto-detect: falls back to human-readable text handler when stdout is a terminal
- Add *Context family (InfoContext, WarnContext, ErrorContext, DebugContext) that
inject trace_id/span_id when an OTel span is active on the context
- Add otelHandler wrapper on every slog.Handler for native trace correlation
- Harden Mask(): URL credential redaction (user:pass@ → ***@), prefix+suffix truncation,
clamp prefix 4–20, handle empty/short strings gracefully
- Add 30 test cases covering Mask, level parsing, concurrent SetLevel, JSON/text output,
env config, and context enrichment (all -race clean)1 parent b018f10 commit 19fc7f8
6 files changed
Lines changed: 658 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | 148 | | |
140 | 149 | | |
| |||
0 commit comments