Write JSON logs in the shape Portainer's viewer reads (1.3.0) #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/portainer-logs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
log.format: jsonnow writes the shape Portainer's log viewer colours:time(localYYYY-MM-DD HH:mm:ss),level,caller,message, and astack_tracearray on errors.logger/portainer.go(new): an encoder config, a level encoder that folds dpanic/panic/fatal intoerror, and a core wrapper that turns zap's stack string into an array of up to 12{func, source, line}frames, module path trimmed.logger/loader.go: a three-line hook for the json format.consoleis unchanged.callerstays zap'spackage/file.go:linerather than closed phase tags: Portainer shows the last two segments, which is exactly that, and phase tags would touch nearly every upstream log call. Recorded in CLAUDE.md.🤖 Generated with Claude Code
Portainer's JSON log viewer colours exactly five keys: time (a string), level, caller, message and stack_trace (an array of {func, source, line}). zap's production JSON used ts, msg and a stacktrace string, so every line rendered as plain trailing fields. logger/portainer.go builds the json logger: time as local "2006-01-02 15:04:05", lowercase levels with dpanic/panic/fatal folded into error, and a core wrapper that moves zap's stack string into a stack_trace array of at most 12 frames, module path trimmed from the function names. caller stays zap's package/file.go:line, the two segments Portainer shows; phase tags would touch nearly every upstream log call. The console format is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>