Giter Club home page Giter Club logo

nested-logrus-formatter's Introduction

nested-logrus-formatter

Build Status Go Report Card GoDoc

Human-readable log formatter, converts logrus fields to a nested structure:

Screenshot

Configuration:

type Formatter struct {
	FieldsOrder     []string // by default fields are sorted alphabetically
	TimestampFormat string   // by default time.StampMilli = "Jan _2 15:04:05.000" is used
	HideKeys        bool     // to show only [fieldValue] instead of [fieldKey:fieldValue]
	NoColors        bool     // to disable all colors
	NoFieldsColors  bool     // to disable colors only on fields and keep levels colored
	ShowFullLevel   bool     // to show full level (e.g. [WARNING] instead of [WARN])
	TrimMessages    bool     // to trim whitespace on messages
}

Usage

import (
	nested "github.com/antonfisher/nested-logrus-formatter"
	"github.com/sirupsen/logrus"
)

log := logrus.New()
log.SetFormatter(&nested.Formatter{
	HideKeys:    true,
	FieldsOrder: []string{"component", "category"},
})

log.Info("just info message")
// Output: Jan _2 15:04:05.000 [INFO] just info message

log.WithField("component", "rest").Warn("warn message")
// Output: Jan _2 15:04:05.000 [WARN] [rest] warn message

Development

# run tests:
make test

# run demo:
make demo

nested-logrus-formatter's People

Contributors

antonfisher avatar nine9ths avatar

Watchers

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