Giter VIP home page Giter VIP logo

pz's Introduction

Prettier Zap

Build Status Coverage Status Go Report Card

in simple terms, it pretty prints zap logs and let you query them!

Prettier Logo

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 the caller field set to the user-code string

asciicast

How To Install?

go get -u github.com/hadisinaee/prettierzap
# or
go dep ensure --add github.com/hadisinaee/prettierzap

How To Use It?

Quick Start

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

Query Base On A Level

You can make a query for a specific log level by adding -l log_level:

go run main.go | pz -l info

Query Base On A Timestamp

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

Query Base On A Caller

You can make a query for a specific caller function by adding a -c caller:

go run main.go| pz -c authentication

Query Base On a Key-Value Pair

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

CLI Help

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

pz's People

Contributors

hadisinaee avatar

Stargazers

Younes Mahmoudi avatar Sadegh avatar Sina Bakhtiari  avatar Mohsen Mirzakhani avatar Souki Aoba avatar Renato Assis avatar Gustavo Pantuza avatar GuiltyMorishita avatar Milad Doorbash avatar Hossein Taghi-Zadeh avatar Koichi Shiraishi avatar Alireza Ahmadi avatar David Smith avatar  avatar Masoud Mirzaei avatar Yasser Souri avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.