https://github.com/zgiber/logfilter
pass through filter for displaying (specific) JSON logs alongside text logs in a somewhat uniform way
https://github.com/zgiber/logfilter
json-logger logging structured-logging
Last synced: 9 months ago
JSON representation
pass through filter for displaying (specific) JSON logs alongside text logs in a somewhat uniform way
- Host: GitHub
- URL: https://github.com/zgiber/logfilter
- Owner: zgiber
- License: mit
- Created: 2019-04-23T09:59:37.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-23T10:23:33.000Z (about 7 years ago)
- Last Synced: 2025-06-06T07:51:37.538Z (about 1 year ago)
- Topics: json-logger, logging, structured-logging
- Language: Go
- Size: 10.7 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# What?
Display logs which are mixed JSON & text outputs in a human readable format. It's written specifically for one use case but displays any JSON formatted log.
Log entries must be newline delimited, one JSON log entry must be a single line.
There are a few fields which it does understand and prints with special formatting:
- time (RFC3339)
- level (string)
- msg (string)
# How?
## Install the tool
`go get -u github.com/zgiber/logfilter`
## Feed it with things
```
▸ logfilter git:(master) cat ~/jsonlog.json
{"level":"debug","file":"stuff.go:34","time":"2018-01-01T23:12:34.456Z","msg":"something happened"}
{"level":"info","file":"stuff.go:34","time":"2018-01-01T23:12:34.456Z","msg":"something happened"}
{"level":"warning","file":"stuff.go:34","time":"2018-01-01T23:12:34.456Z","msg":"something happened"}
{"level":"error","file":"stuff.go:34","time":"2018-01-01T23:12:35.456Z","msg":"something else happened","trace_id":"000001","my mood is":"great"}
01-01-2018T11:11:11.111 INFO Some process has started
01-01-2018T11:11:12.111 ERROR
stacktrace
comes in multiple lines
which are not linked by anything
{"level":"INFO","file":"stuff.go:34","time":"2018-01-01T23:12:36.456Z","msg":"something else happened again"}
{"level":"ERROR","file":"stuff.go:34","time":"2018-01-01T23:12:37.456Z","msg":"something else happened yet again\n\tin multiple lines\n\tbecause we can"}
▸ logfilter git:(master) cat ~/jsonlog.json | logfilter
2018-01-01T23:12:34.456Z [debug] 'something happened' file=stuff.go:34
2018-01-01T23:12:34.456Z [info] 'something happened' file=stuff.go:34
2018-01-01T23:12:34.456Z [warning] 'something happened' file=stuff.go:34
2018-01-01T23:12:35.456Z [error] 'something else happened' file=stuff.go:34 trace_id=000001 my mood is=great
01-01-2018T11:11:11.111 INFO Some process has started
01-01-2018T11:11:12.111 ERROR
stacktrace
comes in multiple lines
which are not linked by anything
2018-01-01T23:12:36.456Z [INFO] 'something else happened again' file=stuff.go:34
2018-01-01T23:12:37.456Z [ERROR] 'something else happened yet again
in multiple lines
because we can' file=stuff.go:34
```
# Notes
At the moment this is a single purpose tool, without much reason to have it changed.
One nice feature would be to support multiline JSON without too much overhead.