5 releases

0.1.4 Feb 11, 2024
0.1.3 Feb 9, 2024
0.1.2 Feb 9, 2024
0.1.1 Feb 9, 2024
0.1.0 Feb 8, 2024

#186 in Command-line interface




jlf is a simple cli for formatting json logs.

Given some log file as below:


{"timestamp": "2024-02-09T07:22:41.439284", "level": "DEBUG", "message": "User logged in successfully", "data": {"user_id": 3175, "session_id": "Nsb3P5mZ7971NFIt", "ip_address": "", "action": "login", "success": false, "error_code": null}}
{"timestamp": "2024-02-09T07:22:42.439284", "level": "ERROR", "message": "Database connection established", "data": {"user_id": 8466, "session_id": "ZMOXKPna3GbzWz2N", "ip_address": "", "action": "logout", "success": true, "error_code": null}}

You can format it using jlf as below:

cat ./examples/dummy_logs | jlf

It will output the logs in a more colorful and readable format:

Screenshot 2024-02-09 at 12 23 12 PM



cargo install jlf


You can also clone the repo and install it manually.

git clone https://github.com/PoOnesNerfect/jlf.git
cd jlf
cargo install --path . --locked

Custom Formatting

You can optionally provide your custom format.

cat ./examples/dummy_logs | jlf '{timestamp:dimmed} {level|lvl:level} {message|msg|body}'

Above will print the logs with dimmed timestamp, blue level and message as is. Above format is actually the default format.

{timestamp:dimmed} means that the cli will look for timestamp in the json and print it with dimmed dimmed.

level|lvl means that the cli will look for level and lvl in the json and use the first one it finds.


Functions in jlf start with # inside {}.


log is a convenience function that prints the basic log format.

cat ./examples/dummy_logs | jlf '{#log}'


cat ./examples/dummy_logs | jlf '{timestamp:dimmed} {level|lvl:level} {message|msg|body}'

and will print

2024-02-09T07:22:41.439284 DEBUG User logged in successfully


You can provide styles to the values by providing styles after the :.

cat ./examples/dummy_logs | jlf '{timestamp:bright blue,bg=red,bold} {level|lvl:level} {message|msg|body:fg=bright white}'

If you have multiple styles, you can separate them with ,.

You can optionally provide the style type before the =. If you don't provide it, it will default to fg.

Available Colors

You can view all available colors in colors.md.


~159K SLoC