Skip to main content

Strict Text Template Parsing

Project description

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]'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json-log-display-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

json_log_display-0.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file json-log-display-0.0.1.tar.gz.

File metadata

  • Download URL: json-log-display-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for json-log-display-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3345ece8333c5acbaa14f2eb1087380ace99f54546f4c98e583642ea7196c3b5
MD5 ce3440b454c1076d1eb1b2566910aab5
BLAKE2b-256 2ec4298c443ef7353f1a2e8d6d7bc5f54dad90c5cccd96f7a5e18de84d1227e0

See more details on using hashes here.

File details

Details for the file json_log_display-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for json_log_display-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0b462b6890d12453c241643804541a98f0d577dd46fd67598384ad709c2e4ae4
MD5 9a4e971f7757e615ac6c3b9a00c7449b
BLAKE2b-256 32a498a199f1000f74398080555f545be08b70dce1d33bda671cd5857f3cd852

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page