-
Notifications
You must be signed in to change notification settings - Fork 221
Description
The core logger hardcodes its prefix (severity + timestamp + optional color) inside toLog and only allows full decoration on/off via ToggleDecoration(). Embedding apps (e.g. servers with their own timestamps or structured logging) need finer control.
Proposal:
Add: // SetPrefixFormatter installs a callback run per log line. // Returning "" emits no prefix. Passing nil restores default. func SetPrefixFormatter(f func(sev Severity, t time.Time) string)
Default keeps current behavior (backward compatible).
ToggleDecoration can internally switch between default formatter and a no-op.
Document concurrency expectations (must be fast, thread-safe, minimal allocs).
Benefits:
Unify formatting across subsystems.
Allow removing duplicate timestamps.
Path toward structured / JSON logging.
Non-goals (initial):
Per-module log levels
Full structured logger replacement
Acceptance:
No behavior change if never called.
Tests: default unchanged; custom formatter applied.