modulepackage
0.0.0-20180912100710-b76d97958f28
Repository: https://github.com/brickchain/go-logger.v1.git
Documentation: pkg.go.dev
# README
Logging framework for Integrity components
This logger components is used by Integrity components that logs output.
Based on Logrus.
It manages logger context and settings on a global level by using the package level functions.
Usage
package main
import (
"github.com/brickchain/go-logger.v1"
"os"
)
func main() {
logger.SetOutput(os.Stdout)
logger.SetFormatter("json")
logger.SetLevel("debug")
logger.AddContext("some_key", "some_value")
localLogger := logger.WithField("my_local_key", "my_local_value")
localLogger.Info("Test")
}
# Functions
AddContext adds another context to the logger.
Debug is the wrapper for Logrus Debug().
Debugf is the wrapper for Logrus Debugf().
Error is the wrapper for Logrus Error().
Errorf is the wrapper for Logrus Errorf().
Fatal is the wrapper for Logrus Fatal().
Fatalf is the wrapper for Logris Fatalf().
ForContext TODO docs.
GetLogger returns the context logger.
GetLoglevel returns the current log level.
Info is the wrapper for Logrus Info().
Infof is the wrapper for Logrus Infof().
SetFormatter sets the formatter to be used, either "json" or "text".
SetLevel sets the lowest level to log.
SetLogrusFormatter sets the logrus formatter to be used.
SetOutput sets the io.Writer to use.
Warn is the wrapper for Logrus Warn().
Warningf is the wrapper for Logrus Warningf().
WithField adds another field to the logger entry context.
WithFields adds more Fields to the logger entry context.
# Type aliases
Fields is a map of fields used by the logger.