Releases
-
released this
2026-04-28 14:36:03 +03:00 | 0 commits to main since this releaseThis release adds JSON HTML-escaping control while preserving the existing
JSON writer defaults and newline semantics.Added
- Added
Formatter.SetJSONEscapeHTML(bool)andFormatter.JSONEscapeHTMLto control whether JSON writers escape HTML-sensitive characters such as<,>, and&.
Changed
- JSON writers now use
json.Encoderinternally so formatter-level HTML escaping can be configured.
Fixed
- Preserved
PrintandPrintlnnewline behavior for JSON output while switching tojson.Encoder.
Compatibility
- No breaking API changes.
- HTML escaping remains enabled by default, matching the previous
encoding/jsonbehavior. Printstill emits JSON without an added newline, andPrintlnemits exactly one trailing newline.
Full Changelog: v2.2.0...v2.3.0
Downloads
- Added
-
released this
2026-04-28 09:45:40 +03:00 | 2 commits to main since this releaseThis release expands the public LogLevel API, adds optional threshold-based
filtering alongside the legacy severity ordering, and improves documentation
and test coverage.Added
- Added dedicated log level constructors:
NewInfoLogLevelNewInfoLogLevelWithColorsNewWarnLogLevelNewWarnLogLevelWithColorsNewErrorLogLevelNewErrorLogLevelWithColorsNewFatalLogLevelNewFatalLogLevelWithColorsNewDebugLogLevelNewDebugLogLevelWithColors
- Added threshold-aware log level constructors:
NewThresholdLogLevelNewThresholdLogLevelWithColors
- Added HTTP method-specific predefined log levels:
HTTPGetLevelHTTPHeadLevelHTTPPostLevelHTTPPutLevelHTTPPatchLevelHTTPDeleteLevelHTTPOptionsLevelHTTPConnectLevelHTTPTraceLevelHTTPUnknownLevel
- Added
LogLevelForMethod(method string) LogLevelto map HTTP methods to predefined log levels. - Added
Logger.Printf(level, format, args...)for formatted logging with an explicit log level. - Added
Logger.SetThresholdMode(bool)to switch filtering from legacy severity-index ordering to threshold-based ordering. - Added
LogLevel.SameLevel,LogLevel.SameThreshold, andLogLevel.Equalfor severity-only, threshold-only, and full level comparisons.
Changed
- Refactored log level definitions into a dedicated
levels.gofile. - Unified
Logger.PrintandLogger.Printlnthrough a shared internal implementation without changing their behavior. - Common helper constructors such as
NewInfoLogLevelnow also assign threshold values while preserving legacy severity indexes. LogLevel.Equalnow includes threshold configuration in full equality checks.- Expanded test coverage for
Logger.Printf, HTTP level mapping, constructor behavior, threshold filtering, and backward compatibility.
Documentation
- Improved GoDoc coverage for exported types, constructors, formatters, colors, HTTP helpers, and time layouts.
- Documented threshold mode, threshold-aware constructors, level comparison helpers, and explicit-level formatted logging.
- Expanded inline documentation for formatter tokens and default formatter behavior.
- Updated English and Russian README files with threshold-mode examples and comparison guidance.
Compatibility
- No breaking API changes.
- Existing
Print,Println, predefined levels,Level/SetLevel, and color APIs remain compatible. - Legacy severity ordering remains the default; threshold filtering is enabled only when
SetThresholdMode(true)is called. SameLevelremains severity-only for backward compatibility, even when levels carry threshold metadata.
Full Changelog: v2.1.0...v2.2.0
Downloads
- Added dedicated log level constructors:
-
released this
2026-04-27 15:42:24 +03:00 | 5 commits to main since this releaseThis 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
Full Changelog: v2.0.1...v2.1.0
Downloads
-
released this
2026-04-27 09:56:46 +03:00 | 7 commits to main since this releaseWhat's Changed
Fix
- Changed module declaration from
git.scuroneko.dev/scuroneko/slogtogit.scuroneko.dev/scuroneko/sneklog
Full Changelog: v2.0.0...v2.0.1
Downloads
- Changed module declaration from
-
2.0.0 Stable
released this
2026-04-24 15:43:14 +03:00 | 8 commits to main since this releaseHighlights
- Renamed the public Go package from
slogtosneklogto avoid confusion with the standard librarylog/slogpackage. - Moved the module path to
git.scuroneko.dev/scuroneko/slog/v2for 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/colordependency tree. - Formatters: a new way do display your logs!
Breaking Changes
- Import paths must use the
/v2module suffix:
import sneklog "git.scuroneko.dev/scuroneko/slog/v2"- Package references should use
snekloginstead ofslog. - Removed
Logger.PrintTimeandLogger.PrintTraceback; configure output through writer formatters instead. - Changed text writer constructors:
CreateTextWriter(w, printTraceback, printTime)is nowCreateTextWriter(w).CreateTextFileWriter(path, printTraceback, printTime)is nowCreateTextFileWriter(path).CreateTextStdoutWriter(printTraceback, printTime)is nowCreateTextStdoutWriter().
- Removed the old text formatting helpers:
BuildString,FormatTime,FormatTraceback, andFormatFullTraceback. - JSON
timevalues are now formatted through the configured formatter and stored as strings inLoggerJsonMessage.
Added
Formatterfor configurable message layouts, timestamp layouts, traceback layouts, separators, and color behavior.DefaultTextFormatterandDefaultJsonFormatterdefaults for text and JSON writers.LoggerTextWriter.SetFormatterandLoggerJsonWriter.SetFormatter.- Strftime-like timestamp format constants such as
RFC3339,Kitchen,DateTime,DateOnly, andTimeOnly. - Built-in color types and helpers:
FgColor,BgColor, andAttribute.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
DefaultTextFormatterinstead of the old hard-coded string builder. - JSON output defaults to
DefaultJsonFormatterand can now format the JSONmessagefield throughFormatter. - Newline semantics are normalized before text and JSON formatting, so trailing
\ncontrols 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/colorgithub.com/mattn/go-colorablegithub.com/mattn/go-isattygolang.org/x/sys
Fixed
NewFormatter()now returns a fresh copy instead of mutatingDefaultTextFormatter.Formatter.FormatMessageno longer panics when called with an empty traceback.- Placeholder-looking text inside log messages, such as
%Lor%s, is preserved literally. SetColorOutput(false)disables color output.SetColorOnlyStdout(false)allows color output for non-stdout writers.
Migration
Before:
import "git.scuroneko.dev/scuroneko/slog" logger := slog.CreateLogger(). Prefix("API"). Level(slog.DEBUG). PrintTraceback(true) text := logger.CreateTextStdoutWriter()After:
import sneklog "git.scuroneko.dev/scuroneko/slog/v2" logger := sneklog.CreateLogger(). Prefix("API"). Level(sneklog.DEBUG) formatter := sneklog.NewFormatter(). SetFormat("%t [%L] %N: %m (%B)") text := logger.CreateTextStdoutWriter(). SetFormatter(formatter)Downloads
- Renamed the public Go package from
-
1.2.0 Stable
released this
2026-04-20 18:11:30 +03:00 | 9 commits to main since this releaseHighlights
- 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.Printno longer panics when called with no message arguments.LoggerJsonWriter.Printnow treats a trailing newline at the end of the last message as newline semantics and does not include that newline in the JSONmessagefield.- 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/colorfromv1.18.0tov1.19.0github.com/mattn/go-isattyfromv0.0.20tov0.0.21golang.org/x/sysfromv0.42.0tov0.43.0
Compatibility
No breaking API changes are intended in this release. The public
LoggerWriterinterface continues to acceptmessages ...any.Downloads
- Added message replacement with
-
1.1.0 Stable
released this
2026-03-17 14:43:28 +03:00 | 14 commits to main since this releaseWhat's changed
This release fixes a shutdown bug in
slogcaused by recursive error logging and unsafe writer ownership.Fixed
Logger.Close()no longer logswriter.Close()errors through the same logger instance- writer errors during
print/printlnno longer trigger recursivel.Error(err)calls - stdout-based writers no longer close
os.Stdout - generic
CreateTextWriter/CreateJsonWriterno longer close externally provided writers Close()now returns aggregated writer close errors instead of silently returningnil- non-closable external writers no longer cause panics on
Close()
Internal changes
- file-based writers explicitly own and close the files they create
- stdout and externally injected writers are treated as non-owning
- added regression tests for:
- writer
Print()errors without recursion - aggregated
Close()errors - safe
Close()behavior for stdout writers - safe
Close()behavior for non-owning external writers
- writer
Impact
This removes a class of hangs / recursion failures during logger shutdown and makes writer lifecycle behavior explicit and predictable.
Compatibility note
CreateTextWriter(io.Writer, ...)andCreateJsonWriter(io.Writer, ...)are now non-owning by design. If you pass a closable writer such as*os.Filethrough these constructors, closing that writer is now the caller's responsibility. If you want the logger to own the file lifecycle, useCreateTextFileWriter(...)orCreateJsonFileWriter(...).Downloads