in simple terms, it pretty prints zap logs and let you query them!
If you are using Zap Logger, you can use Prettier Zap
cli for:
- making the raw JSON outputs of Zap more readable for developer
- making query base on
timestamp
,level
,caller
or a specific(key, value)
pair
all non-zap logs are treated as
debug
logs with thecaller
field set to theuser-code
string
go get -u github.com/hadisinaee/prettierzap
# or
go dep ensure --add github.com/hadisinaee/prettierzap
If your program logs into stdout
, you can simply pipe it to the pz
command:
go run main.go | pz
or if it's written to a file:
tail -f .log | pz
You can add a -e
to all the following commands to make the logs look funny with emojis:
go run main.go | pz -e
You can make a query for a specific log level by adding -l log_level
:
go run main.go | pz -l info
You can make a query for all logs of today by adding a -t today
:
go run main.go | pz -t today
You can make a query for all logs which are generated from now on by adding a -t now
:
go run main.go | pz -t now
You can make a query for all logs which are generated after a specific timestamp by adding a -t 123456789
:
go run main.go | pz -t 123456789
You can make a query for a specific caller function by adding a -c caller
:
go run main.go| pz -c authentication
If your logs have key value pairs and you are looking for logs with a specific key-value pair, you can add a k key_1=value_1
:
go run main.go| pz -k req_id="abcdef1234="
# or
go run main.go| pz -k req_id="abcdef1234=",uid=10230212
>> pz -h
NAME:
Prettier Zap - make zap logs more beautiful and queryable
USAGE:
pz [global options] command [command options] [arguments...]
VERSION:
0.9.1
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
-l log_level, --level log_level just logs with log level of log_level
-t timestamp, --timestamp timestamp just logs after the timestamp(>=). it is possible to use the following keywords with `timestamp`:
now: to show all logs from the current time
today: to show all logs of the tody(start from 00:00)
-c caller_name, --caller caller_name just logs that its caller field contains caller_name
-k key_1=value_1, --keyvalue key_1=value_1 just logs that have specific pairs of key_1=value_1
-e, --emoji add some funny emoji to output
--help, -h show help
--version, -v print the version