FILE / ScuroNeko/SNekLog

RELEASE_NOTES.md

Исходный файл и его история в репозитории.
FILE 812caed47188b07cdbcc4251a5745382032e1df7
Files
SNekLog/RELEASE_NOTES.md
T
ScuroNeko 812caed471
Golang lint / lint (push) Successful in 42s
(new): add log level helpers and HTTP method levels
- move LogLevel and predefined levels into levels.go
- add level-specific constructors for info/warn/error/fatal/debug
- add predefined HTTP method log levels and LogLevelForMethod
- unify Logger Print/Println internals and add Printf
- improve GoDoc coverage for exported APIs
2026-04-27 16:36:30 +03:00

196 lines
7.5 KiB
Markdown

# v2.2.0
This release adds new public APIs for working with log levels, introduces HTTP method-specific log levels, and improves package documentation.
### Added
- Added dedicated log level constructors:
- `NewInfoLogLevel`
- `NewInfoLogLevelWithColors`
- `NewWarnLogLevel`
- `NewWarnLogLevelWithColors`
- `NewErrorLogLevel`
- `NewErrorLogLevelWithColors`
- `NewFatalLogLevel`
- `NewFatalLogLevelWithColors`
- `NewDebugLogLevel`
- `NewDebugLogLevelWithColors`
- Added HTTP method-specific predefined log levels:
- `HTTPGetLevel`
- `HTTPHeadLevel`
- `HTTPPostLevel`
- `HTTPPutLevel`
- `HTTPPatchLevel`
- `HTTPDeleteLevel`
- `HTTPOptionsLevel`
- `HTTPConnectLevel`
- `HTTPTraceLevel`
- `HTTPUnknownLevel`
- Added `LogLevelForMethod(method string) LogLevel` to map HTTP methods to predefined log levels.
- Added `Logger.Printf(level, format, args...)` for formatted logging with an explicit log level.
### Changed
- Refactored log level definitions into a dedicated `levels.go` file.
- Unified `Logger.Print` and `Logger.Println` through a shared internal implementation without changing their behavior.
### Documentation
- Improved GoDoc coverage for exported types, constructors, formatters, colors, HTTP helpers, and time layouts.
- Expanded inline documentation for formatter tokens and default formatter behavior.
### Compatibility
- No breaking API changes.
- Existing `Print`, `Println`, predefined levels, and color APIs remain compatible.
# v2.1.0
This release expands sneklog color customization while preserving compatibility with the v2.0.1 API.
## Added
- custom LogLevel constructors with configurable colors
- 256-color and RGB support for LogLevel
- ANSI text attributes on LogLevel such as Bold and Italic
- typed color helpers for foreground/background RGB and 256-color values
- NewLogger, SetName, SetLevel, and SetJSONPretty as clearer preferred APIs
## Improved
- text and JSON writer handling of trailing newline semantics
- formatter colorization logic for foreground, background, and attributes
- GoDoc coverage across the public API
- English and Russian README examples and API guidance
## Compatibility
- legacy APIs from v2.0.1 remain available as deprecated wrappers
- legacy ColorStringBuilder method signatures were preserved for backward compatibility
- deprecated methods now explicitly document their replacements and planned removal in v3
## Fixed
- extra separator/space issues in Println-style output
- attribute slice handling and defensive copying for LogLevel
- color mode precedence when switching between ANSI, 256-color, and RGB modes
# v2.0.0
## Highlights
- Renamed the public Go package from `slog` to `sneklog` to avoid confusion with the standard library `log/slog` package.
- Moved the module path to `git.scuroneko.dev/scuroneko/sneklog/v2` for Go module major-version compatibility.
- Replaced fixed text writer settings with formatter-based output customization.
- Added built-in ANSI color support and removed the external `github.com/fatih/color` dependency tree.
- Formatters: a new way do display your logs!
## Breaking Changes
- Import paths must use the `/v2` module suffix:
```go
import "git.scuroneko.dev/scuroneko/sneklog/v2"
```
- Package references should use `sneklog` instead of `slog`.
- Removed `Logger.PrintTime` and `Logger.PrintTraceback`; configure output through writer formatters instead.
- Changed text writer constructors:
- `CreateTextWriter(w, printTraceback, printTime)` is now `CreateTextWriter(w)`.
- `CreateTextFileWriter(path, printTraceback, printTime)` is now `CreateTextFileWriter(path)`.
- `CreateTextStdoutWriter(printTraceback, printTime)` is now `CreateTextStdoutWriter()`.
- Removed the old text formatting helpers: `BuildString`, `FormatTime`, `FormatTraceback`, and `FormatFullTraceback`.
- JSON `time` values are now formatted through the configured formatter and stored as strings in `LoggerJsonMessage`.
## Added
- `Formatter` for configurable message layouts, timestamp layouts, traceback layouts, separators, and color behavior.
- `DefaultTextFormatter` and `DefaultJsonFormatter` defaults for text and JSON writers.
- `LoggerTextWriter.SetFormatter` and `LoggerJsonWriter.SetFormatter`.
- Strftime-like timestamp format constants such as `RFC3339`, `Kitchen`, `DateTime`, `DateOnly`, and `TimeOnly`.
- Built-in color types and helpers:
- `FgColor`, `BgColor`, and `Attribute`.
- `ColorStringBuilder`.
- Level color getters/setters on `LogLevel`.
- Tests covering formatter defaults, empty traceback placeholders, literal `%` sequences in messages, color controls, and JSON newline semantics.
## Changed
- Text output defaults to `DefaultTextFormatter` instead of the old hard-coded string builder.
- JSON output defaults to `DefaultJsonFormatter` and can now format the JSON `message` field through `Formatter`.
- Newline semantics are normalized before text and JSON formatting, so trailing `\n` controls record termination without becoming part of the message.
- Text color output is enabled by default only for stdout/stderr.
- Example code now demonstrates custom formatters and color configuration.
- Go dependencies were simplified by removing:
- `github.com/fatih/color`
- `github.com/mattn/go-colorable`
- `github.com/mattn/go-isatty`
- `golang.org/x/sys`
## Fixed
- `NewFormatter()` now returns a fresh copy instead of mutating `DefaultTextFormatter`.
- `Formatter.FormatMessage` no longer panics when called with an empty traceback.
- Placeholder-looking text inside log messages, such as `%L` or `%s`, is preserved literally.
- `SetColorOutput(false)` disables color output.
- `SetColorOnlyStdout(false)` allows color output for non-stdout writers.
## Migration
Before:
```go
import "git.scuroneko.dev/scuroneko/slog"
logger := slog.CreateLogger().
Prefix("API").
Level(slog.DEBUG).
PrintTraceback(true)
text := logger.CreateTextStdoutWriter()
```
After:
```go
import sneklog "git.scuroneko.dev/scuroneko/sneklog/v2"
logger := sneklog.CreateLogger().
Prefix("API").
Level(sneklog.DEBUG)
formatter := sneklog.NewFormatter().
SetFormat("%t [%L] %N: %m (%B)")
text := logger.CreateTextStdoutWriter().
SetFormatter(formatter)
```
# 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`.