chore: update console logging docs and pipeline behavior

This commit is contained in:
2026-03-04 22:21:59 +03:00
parent 762f53e9a8
commit d3fef656ed
4 changed files with 250 additions and 3 deletions

View File

@@ -32,6 +32,16 @@ logFile, err := consolex.SetupDefaultSlog(consolex.LoggerConfig{
ArchiveDir: "logs",
Level: slog.LevelDebug,
Theme: consolex.NordTheme(),
Dedupe: consolex.DedupeConfig{
Enabled: true,
Remap: []consolex.LevelRemapRule{
{
From: "INFO",
To: "DEBUG",
Contains: []string{"conn write packet failed", "context canceled"},
},
},
},
FieldProvider: consolex.StaticFieldProvider{
"proto_id": consolex.New().White().BgBlue().Bold(),
"raddr": consolex.New().Black().BgYellow(),
@@ -58,6 +68,40 @@ logFile, err := consolex.SetupDefaultSlog(consolex.LoggerConfig{
}
```
## Dedup/Aggregation (`xN`)
Enable duplicate line aggregation in `LoggerConfig.Dedupe`:
```go
cfg := consolex.LoggerConfig{
Level: slog.LevelDebug,
Dedupe: consolex.DedupeConfig{
Enabled: true,
Window: time.Second, // default: 1s
},
}
```
Repeated identical lines are collapsed and emitted once with:
- `repeat="xN"`
Example:
```text
time=... level=INFO msg="conn write packet failed" packet=*packet.UpdateBlock err="context canceled" repeat="x37"
```
You can also remap levels by rules:
```go
Dedupe: consolex.DedupeConfig{
Enabled: true,
Remap: []consolex.LevelRemapRule{
{From: "INFO", To: "DEBUG", Contains: []string{"context canceled"}},
},
},
```
## Chalk-like style API
```go