Convert structured JSON logs to human-readable output
Project description
jsonlog-cli
A human readable formatter for JSON logs.
It's built for use with jsonlog but will work well with any log format that uses line delimited JSON.
Usage
See jsonlog --help
for all options.
Key-value mode
Pass a file as the only argument to jsonlog
, or read from STDIN by default.
jsonlog kv docs/example.log
python docs/example.py | jsonlog kv
cat docs/example.log | jsonlog
Only show the timestamp
and message
fields:
jsonlog kv --key timestamp --key message docs/example.log
Configure the keys of multiline values you want to display (can be specified
multiple times, and defaults to the traceback
key.)
jsonlog kv --key timestamp --key message --multiline-key traceback docs/example.log
Configure the key to extract and use as the records level, controlling the
colour each line is printed in (defaults to the level
key).
jsonlog kv --level-key level --key timestamp --key message --multiline-key traceback docs/example.log
Template mode
Only show the timestamp
and message
fields:
jsonlog template --format "{timestamp} {message}" docs/example.log
Also show a multiline key when it's present:
jsonlog template --format "{timestamp} {message}" --multiline-key traceback docs/example.log
Configuration
Named "patterns" are supported as a way of collecting a set of options for
jsonlog's key-value and template modes. If ~/.config/jsonlog/config.json
exists, it will be loaded at startup. All fields should be optional.
The example configuration file below creates patterns named example
and
defaults
for the key-value and template modes. The patterns named example
will show the timestamp
and message
fields of incoming logs. The patterns
named defaults
set all fields to their default values.
{
"keyvalues": {
"example": {
"priority_keys": ["timestamp", "message"]
},
"defaults": {
"level_key": "level",
"multiline_json": false,
"multiline_keys": [],
"priority_keys": [],
"removed_keys": []
}
},
"templates": {
"example": {
"format": "{timestamp} {message}"
},
"defaults": {
"level_key": "level",
"multiline_json": false,
"multiline_keys": [],
"format": "{timestamp} {message}"
}
}
}
Authors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jsonlog_cli-5.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28ab6989f9d5215d7a8ea3ad955336a6cc03707c431643da7653d96efad35e98 |
|
MD5 | 9ea83a683e409f13a534af1defa3f53b |
|
BLAKE2b-256 | 9ea71a38202606cb35491e0ccf38b9b2adff44db4739c752c617a3ad87d07963 |