Skip to content
This repository has been archived by the owner on Dec 15, 2019. It is now read-only.

aellwein/slf4go-logrus-adaptor

Repository files navigation

Go Report Card Coverage Status Build Status

Logrus adaptor for SLF4GO

This is a Logrus adaptor implementation for SLF4GO.

An example usage is stupid simple:

package main

import (
	"github.com/aellwein/slf4go"
	_ "github.com/aellwein/slf4go-logrus-adaptor"
)

func main() {
    logger := slf4go.GetLogger("mylogger")
    
    logger.SetLevel(slf4go.LevelInfo)
    
    logger.Debug("don't see me!")
    logger.Info("It works!")
    logger.Warnf("The answer is %d", 42)
}

Note the underscore in front of the import of the SLF4GO adaptor.

You can change the logger implementation anytime, without changing the facade you are using, only by changing the imported adaptor.

Logging parameters

This adaptor supports several parameters, available with SetLoggingParameters:

Parameter Key Value Type Description
"formatter" logrus.Formatter Logrus Formatter to use
"output" io.Writer Ouput writer as defined by Logrus
"level" logrus.Level Log level to use
"fields" logrus.Fields A map containing fields to be included in output
"hooks" []logrus.Hook List of hooks to be used with Logrus

Development

  • use go build ./... as usual.