Giter VIP home page Giter VIP logo

prettylog's Introduction

Pretty Log

Displaying tool for JSON structured logs in compatible format to humans.

Prettylog

Installation

curl https://github.com/globocom/prettylog/raw/master/install.sh | sh

Assuming that the folder $GOPATH/bin is inside the user's actual PATH, the application will be available after the installation.

Running

Prettylog processes logs containing an arbitrary number of fields, and creates a friendly output in the following format:

<TIMESTAMP> <LOGGER> <CALLER> <LEVEL> <MESSAGE> <FIELD1>=<VALUE> <FIELD2>=<VALUE> ...

If a specific field does not exist in the log, it will be ignored on the output.

NOTE: Nowadays, only logs on JSON format are supported. Logs in another format, or without one, will be printed without any modification

Utilization

The tool was designed to read directly the stdout from an application that produces logs in a structured format:

app | prettylog

If the application writes logs on sterr instead of stdout, a redirect is required so the tool can work properly:

app 2>&1 | prettylog

Settings

The tool can be configured through the .prettylog.yml file, which can be found either locally(on the folder that the tool runs) or globally (in the folder $HOME). The file structure is as follows:

timestamp: key: visible: color:

logger:
  key:     <string>
  visible: <bool>
  padding: <int>
  color:   <list of int>

caller:
  key:     <string>
  visible: <bool>
  padding: <int>
  color:   <list of int>

level:
  key:     <string>
  visible: <bool>
  padding: <int>
  colors:
    debug: <list of int>
    info:  <list of int>
    warn:  <list of int>
    error: <list of int>
    fatal: <list of int>

message:
  key:     <string>
  padding: <int>
  color:   <list of int>

Each key configures the format of the field in the log, and the meaning of each property is described bellow:

  • key: Name of the field that will be extracted from the log of the application.
  • visible: Flag indicating whether the field will be displayed by the tool or not.
  • padding: Amount of blank spaces that will be added to the right of the field text.
  • color/colors: Color attributes used for coloring the field text. Up to 3 values ​​can be entered (foreground, background e effects) according to ASCII colors chart.

Utilization with other command line tools

Prettylog can be used with other processing output tools like grep. However, for the formatting of the output to be done correctly, it is necessary to turn off any non-line buffer. For example, with grep just use the --line-buffered option:

app | grep --line-buffered -v debug | prettylog

If the tool makes use of a buffer and does not provide a native way to turn it off, try using the stdbuff.

prettylog's People

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.