Skip to main content

JSON log display (json-log-display)

A CLI tool for presenting JSON logging data nicely on the CLI. If there is additional non JSON data it will attempt to ignore that and use the valid JSON that is there.

It also colours the output, can pre filter, post filter, pass through or ignore non JSON data and supports an output format string.

Installation

JSON log display requires Python 3.6 or higher.

Install the pip package as follows:

$ pip install json-log-display

Use

Once installed a jld CLI util should be available, and all you have to do is pipe logging which has embedded JSON to it. For example:

$ tail -f /some/log/file | jld
2022-10-29T16:56:11.646734D INFO some info
2022-10-29T16:56:11.693193D DEBUG some debug
2022-10-29T16:56:11.646734D INFO more info
2022-10-29T16:56:11.646734D INFO warning alert bad
2022-10-29T16:56:11.646734D ERROR really gone wrong now

The lines will be coloured according to the level.

To change the colour of a level you can either specify a CLI argument, for example --col info=green, or set an environment variable, like JLD_LEVEL_INFO_COL=green.

To change the output format use --out_format, the default format string is ${timestamp} ${level} ${message}". Each ${xxxx} is a deference to a key in the JSON objects logged.

To change the field which is used to determine the log colour use --level_field. For example --level_field loglevel.

To hide non JSON data use --no_passthrough.

To pre filter the input (only include lines matching a given regular expression) use --pre_filter REGEX and provide a regular expression.

To filter the output based on the JSON data use --data_filter KEY=REGEX.

By default JSON log display will attempt to skip junk to find valid JSON log data later in the line. To disable this if this causes problems and your logging does not have a prefix use --no_json_search.

Development

A nox config is provided and Makefile. Install nox if necessary and run nox or run make, which will use your default Python version and create a virtual environment.

You can install development requirements in your current environment as follows:

$ pip install '.[dev]'

Release files for json-log-display 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for json-log-display 0.0.1
File Size Uploaded
json-log-display-0.0.1.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for json-log-display 0.0.1
File Interpreter ABI Platform
json_log_display-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / json-log-display-0.0.1.tar.gz

Download URL json-log-display-0.0.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3345ece8333c5acbaa14f2eb1087380ace99f54546f4c98e583642ea7196c3b5
BLAKE2b-256 checksum
How to use checksums
2ec4298c443ef7353f1a2e8d6d7bc5f54dad90c5cccd96f7a5e18de84d1227e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / json_log_display-0.0.1-py3-none-any.whl

Download URL json_log_display-0.0.1-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b462b6890d12453c241643804541a98f0d577dd46fd67598384ad709c2e4ae4
BLAKE2b-256 checksum
How to use checksums
32a498a199f1000f74398080555f545be08b70dce1d33bda671cd5857f3cd852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page