logrus

package module
v0.0.0-...-461f2d8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2018 License: MIT Imports: 3 Imported by: 7

README

loggers-mapper-logrus

Golang Loggers mapper for Logrus.

GoDoc Build Status

Pre-recquisite

See https://gopkg.in/birkirb/loggers.v1

Installation

go get github.com/birkirb/loggers-mapper-logrus

Usage

Assuming you are using loggers in your code, and you want to use logrus as your logger implementation. Start by configuring your logrus, and then pass it to the mapper and assign it to your loggers interface (embedded use) or the log.Logger (direct package).

Example
package main

import (
	"os"

	"github.com/sirupsen/logrus"
        "gopkg.in/birkirb/loggers.v1"
        mapper "github.com/birkirb/loggers-mapper-logrus/"
)

// Log is my default logger.
var Log loggers.Contextual

func main() {
	l := logrus.New()
	l.Out = os.Stdout
	l.Level = logrus.InfoLevel

	m := mapper.NewLogger(l)
	Log = &m

	Log.Info("My program has started")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDefaultLogger

func NewDefaultLogger() loggers.Contextual

NewDefaultLogger returns a Contextual Logger for Logrus's logger. The logger will contain whatever defaults Logrus uses.

func NewLogger

func NewLogger(logrus *logrus.Logger) loggers.Contextual

NewLogger returns a Contextual Logger for Logrus's logger. Note that any initialization must be done on the input logrus.

Types

type Logger

type Logger struct {
	*logrus.Logger
}

Logger is an Contextual logger wrapper over Logrus's logger.

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) loggers.Advanced

WithField returns an advanced logger with a pre-set field.

func (*Logger) WithFields

func (l *Logger) WithFields(fields ...interface{}) loggers.Advanced

WithFields returns an advanced logger with pre-set fields.

Jump to

Keyboard shortcuts

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