architagr / architagr/LogNugget
V4-P5: deprecate legacy LogAttr{} literal API — route all callers to typed chain methods
- Dominant language
- Go
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Umbrella
#131
## Problem
`model.LogAttr{Key: "iter", Value: 0}` causes:
1. `Value: 0` boxes `int` to `interface{}` → 1 alloc
2. `fields ...model.LogAttr` variadic creates `[]model.LogAttr` at callsite → 1 alloc
3. `KindAny` dispatch in `AppendAttr` does a type-switch → extra branch cost
Typed chain methods (`.Int("k", 0)`) already avoid all three: pre-rendered directly into `pendingBuf`, 0 allocs.
## Solution
- Add `//Deprecated` godoc on `model.LogAttr{}` direct construction and `AppendField`.
- Add `LogEntry.Err(err error)` chain method (common case, saves 1 alloc vs passing `err` to `Error()`).
- Add `LogEntry.Any(key string, val any)` as the explicit escape hatch for KindAny (clearer intent than `LogAttr{Value: x}`).
- Update all internal benchmarks and examples to use chain methods.
## Acceptance criteria
- `Benchmark_Log_Parallel` (with fields via chain): 0 allocs/op (no variadic slice, no boxing)
- Legacy `LogAttr{}` path still compiles and works (no removal — just deprecated)
- `BenchmarkLogEntry_LegacyAttrs_10` kept as regression guard for deprecated path
- `go test ./...` green; godoc shows deprecation notices
Contributor guide
Research direction
Start by tracing model.LogAttr, AppendField, AppendAttr, and the typed LogEntry chain methods, then inspect Benchmark_Log_Parallel and BenchmarkLogEntry_LegacyAttrs_10. Check how the benchmarks and examples construct fields before updating them. Done means the typed benchmark reports 0 allocs/op, the legacy path still works with deprecation notices, and go test ./... passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100