filtered

package module
v0.0.0-...-c79c40a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2018 License: MIT Imports: 3 Imported by: 0

README

Logrus Filtered Formatter

Use this formatter to log json with filtered fields

Usage

package main

import (
	"github.com/Fs02/logrus-filtered-formatter"
	"github.com/sirupsen/logrus"
)

func main() {
	log := logrus.New()
	fields := []string{
		"password",
		"email",
	}
	log.Formatter = filtered.New(fields, &logrus.JSONFormatter{})

	log.WithFields(logrus.Fields{
		"password": "asdfasdf",
		"email":    "johndoe@gmail.com",
		"name":     "john doe",
	}).Info("new user created")
}

Output:

{"email":[FILTERED],"level":"info","msg":"new user created","name":"john doe","password":[FILTERED],"time":"2017-10-05T16:05:29+07:00"}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter formats logs with filtered fields

func New

func New(fields []string, formatter logrus.Formatter) *Formatter

New returns an instance of logrus formatter

func (*Formatter) Format

func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error)

Format renders a single log entry

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL