feat: add message replacement for log records
Add Logger.AddReplacer to mask or normalize message text before records reach writers. Document replacement behavior in README and package GoDoc, and update the example. Also fix JSON writer edge cases: - avoid panic on empty message lists - preserve newline semantics when the last message already ends with n - keep original message argument types for custom writers when no replacers are configured Update dependencies and add release notes for the next release.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# v1.2.0
|
||||
|
||||
## Highlights
|
||||
|
||||
- Added message replacement with `Logger.AddReplacer(old, new)` for masking secrets or normalizing log output.
|
||||
- Preserved the existing `LoggerWriter.Print(...any)` contract, so custom writers do not need a signature update.
|
||||
- Improved JSON writer newline handling for messages that already end with `\n`.
|
||||
|
||||
## Added
|
||||
|
||||
- `Logger.AddReplacer(old, new)` appends a replacement rule that is applied before records are sent to writers.
|
||||
- README and package GoDoc now document message replacement and include usage examples.
|
||||
- Tests covering message type preservation for custom writers, JSON empty messages, and JSON trailing newline behavior.
|
||||
|
||||
## Fixed
|
||||
|
||||
- `LoggerJsonWriter.Print` no longer panics when called with no message arguments.
|
||||
- `LoggerJsonWriter.Print` now treats a trailing newline at the end of the last message as newline semantics and does not include that newline in the JSON `message` field.
|
||||
- Log messages keep their original argument types for custom writers when no replacement rules are configured.
|
||||
|
||||
## Changed
|
||||
|
||||
- Updated the example program to demonstrate `AddReplacer`.
|
||||
- Updated dependencies:
|
||||
- `github.com/fatih/color` from `v1.18.0` to `v1.19.0`
|
||||
- `github.com/mattn/go-isatty` from `v0.0.20` to `v0.0.21`
|
||||
- `golang.org/x/sys` from `v0.42.0` to `v0.43.0`
|
||||
|
||||
## Compatibility
|
||||
|
||||
No breaking API changes are intended in this release. The public `LoggerWriter` interface continues to accept `messages ...any`.
|
||||
Reference in New Issue
Block a user