https://github.com/globocom/prettylog
Logs for human beings
https://github.com/globocom/prettylog
command-line-tool go golang json logs
Last synced: 10 months ago
JSON representation
Logs for human beings
- Host: GitHub
- URL: https://github.com/globocom/prettylog
- Owner: globocom
- License: mit
- Created: 2019-10-01T22:38:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-11T18:40:10.000Z (over 2 years ago)
- Last Synced: 2025-08-03T07:24:33.527Z (11 months ago)
- Topics: command-line-tool, go, golang, json, logs
- Language: Go
- Homepage:
- Size: 9.51 MB
- Stars: 65
- Watchers: 12
- Forks: 24
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Prettylog
Command line tool that displays JSON logs in a human-friendly format.

## Installation
Go 1.17+:
go install github.com/globocom/prettylog@latest
Go 1.16 or older:
curl https://github.com/globocom/prettylog/raw/master/install.sh | sh
Prettylog will be installed to `$GOPATH/bin`. Make sure to add it to your `PATH` so you can run `prettylog` anywhere.
## How it works
Prettylog parses log messages that contain an arbitrary number of fields and generates a nice output in the
following format:
= = ...
Non-existent fields will be ignored and messages not encoded as JSON will be printed as is.
## Usage
Simply pipe the `stdout` of an application that outputs structured log messages into `prettylog`:
app | prettylog
You might need to redirect `stderr` to `stdout` if the application doesn't log to the standard output:
app 2>&1 | prettylog
## Configuration
You can configure how Prettylog works by creating a `.prettylog.yml` file either locally (per directory)
or globally (in `$HOME`):
```yaml
timestamp:
key:
visible:
color:
format:
logger:
key:
visible:
padding:
color:
caller:
key:
visible:
padding:
color:
level:
key:
visible:
padding:
colors:
debug:
info:
warn:
error:
fatal:
message:
key:
padding:
color:
```
Each field has its own key and the following properties are available:
| Name | Description |
| - | - |
|**key**| Field name. |
|**visible**| Flag indicating whether the field will be printed. |
|**padding**| Number of whitespaces that will be added to the right of the field. |
|**color/colors**| Color attributes. Up to 3 values can be used (fg, bg and effects). More information [here](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors). |
|**format**| (timestamp field only) Layout that will be used to print timestamp values. It must follow the rules of the [time package](https://golang.org/pkg/time/#pkg-constants). |
## Using with other tools
Prettylog can be used along with other command line tools. Just make sure no buffer is enabled. For instance, `grep`
has a `--line-buffered` flag:
app | grep --line-buffered -v debug | prettylog
If the tool you want to use buffers its output and does not offer such a flag, you can try
[stdbuff](https://www.gnu.org/software/coreutils/manual/html_node/stdbuf-invocation.html).