pl tails and pretty-prints JSONL logs produced by zap
(the zap.NewProductionConfig JSON encoder, as used by go-faster/sdk).
go install github.com/go-faster/pl/cmd/pl@latestPipe logs in:
my-service 2>&1 | plFollow a file (tail -f style):
pl -f service.logRead a file once and exit:
pl service.logOutput is colorized when stdout is a terminal. Non-JSON lines are passed through
untouched, so mixed output is safe. Disable colors with --no-color or by setting
NO_COLOR.
-f, --follow follow the file, waiting for new lines (like tail -f)
--no-color disable ANSI colors
--no-time omit timestamps from the output
--level minimum level to display (debug|info|warn|error)
--timezone convert timestamps to this timezone (e.g. UTC, Local, America/New_York)
Levels render as a single colored character by default — D, I, W, E,
and C for dpanic/panic/fatal:
03:00:00.099 D verbose detail
03:00:00.200 I metrics Starting attempt=3
03:00:00.299 W disk low note="needs attention"
03:00:00.400 E boom err=x
03:00:00.500 C giving up
When used as a library, override per-level label and color via
Formatter.LevelStyles (levels absent from the map keep their defaults):
f := &pl.Formatter{
Color: true,
LevelStyles: map[zapcore.Level]pl.LevelStyle{
zapcore.WarnLevel: {Label: "WARN", Color: "\033[33m"},
},
}