• Stars
    star
    142
  • Rank 257,749 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Formatter for https://github.com/sirupsen/logrus

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 - default: fields sorted alphabetically
	FieldsOrder []string

	// TimestampFormat - default: time.StampMilli = "Jan _2 15:04:05.000"
	TimestampFormat string

	// HideKeys - show [fieldValue] instead of [fieldKey:fieldValue]
	HideKeys bool

	// NoColors - disable colors
	NoColors bool

	// NoFieldsColors - apply colors only to the level, default is level + fields
	NoFieldsColors bool

	// NoFieldsSpace - no space between fields
	NoFieldsSpace bool

	// ShowFullLevel - show a full level [WARNING] instead of [WARN]
	ShowFullLevel bool

	// NoUppercaseLevel - no upper case for level value
	NoUppercaseLevel bool

	// TrimMessages - trim whitespaces on messages
	TrimMessages bool

	// CallerFirst - print caller info first
	CallerFirst bool

	// CustomCallerFormatter - set custom formatter for caller info
	CustomCallerFormatter func(*runtime.Frame) string
}

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

See more examples in the tests file.

Development

# run tests:
make test

# run demo:
make demo

More Repositories

1

react-simple-timefield

Simple React time input field
TypeScript
93
star
2

react-express-webpack

React boilerplate with ES2015, Express.js, and Webpack 4
JavaScript
83
star
3

node-mocha-extjs

Framework for testing ExtJs applications
JavaScript
19
star
4

gitPushNotify

Git command "push" notifier.
Python
19
star
5

go-media-devices-state

Go module to get camera/microphone state -- checks if camera or microphone is ON
Objective-C++
18
star
6

jenkins-in-docker

Instructions
Dockerfile
18
star
7

utop

CLI tool for single process monitoring written in Node.js
JavaScript
11
star
8

electron-window-rotator

Rotate native Electron window on macOS
Objective-C++
9
star
9

electron-aspect-ratio-browser-window

Drop-in replacement for Electron's BrowserWindow with working aspect ratio on Windows
JavaScript
7
star
10

game-calcuman

React Native Game
JavaScript
5
star
11

rpi-laser-cat-teaser

Laser Cat Teaser built on Raspberry Pi
Go
3
star
12

extjs-d3pie-chart

D3js Pie Chart for ExtJs 4
JavaScript
3
star
13

scd30

Go/TinyGo driver for Sensirion SCD30: ambient CO2, humidity, and temperature sensor module
Go
2
star
14

chrome-gmail-image-border-ext

Chrome extension helps manage image borders in a Gmail letter
JavaScript
2
star
15

sloth-storage

Drive distributed storage on Node.js with FTP interface
JavaScript
2
star
16

flap-app-launcher

Application Launcher based on ElectronJS
JavaScript
2
star
17

ExtJs4Example

Demo app for BARCAMP KRASNODAR & SOUTH OF RUSSIA (2012-04-07, http://barcampsr.ru/)
JavaScript
2
star
18

node-logicmachine-api

LogicMachine Remote services API
JavaScript
1
star
19

static-site-generator

Markdown based static site generator
JavaScript
1
star
20

is31fl3731

Go/TinyGo driver for Lumissil IS31FL3731 matrix LED driver
Go
1
star
21

ExtJsGeneratorFromZF

Generate ExtJs Grigs and Forms from Zend Framework DbModel
PHP
1
star
22

rpi-jenkins-light

Raspberry Pi Jenkins Light on NodeJs
JavaScript
1
star
23

chrome-tabs-top-ext

Chrome extension shows CPU usage in tab's favicon
JavaScript
1
star
24

go-app-template

CLI Go application template
Go
1
star
25

angular2-es6-webpack

Starter Kit for Angular2 with ES6 and Webpack
JavaScript
1
star
26

CityManager

ExtJs interface example for city management
JavaScript
1
star