Documentation ¶
Overview ¶
Package logger is a wrapper for the Logrus logger package.
Logger is used by most Brickchain software to enable context based logging with details needed by each component.
Installation
# How to install logger $ go get github.com/Brickchain/go-logger.v1
Example
logger.SetOutput(os.Stdout) logger.SetFormatter("text") logger.SetLevel("debug") logger.AddContext("service", path.Base(os.Args[0])) logger.AddContext("version", constant.Version) logger.Infof("Running version %s", version) logger.Error(err)
Index ¶
- func AddContext(key string, value interface{})
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func GetLogger() *logrus.Entry
- func GetLoglevel() string
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func SetFormatter(formatter string)
- func SetLevel(level string)
- func SetLogrusFormatter(formatter logrus.Formatter)
- func SetOutput(out io.Writer)
- func Warn(args ...interface{})
- func Warningf(format string, args ...interface{})
- type Entry
- func (e *Entry) AddField(key string, value interface{})
- func (e *Entry) Debug(args ...interface{})
- func (e *Entry) Debugf(format string, args ...interface{})
- func (e *Entry) Error(args ...interface{})
- func (e *Entry) Errorf(format string, args ...interface{})
- func (e *Entry) Fatal(args ...interface{})
- func (e *Entry) Info(args ...interface{})
- func (e *Entry) Infof(format string, args ...interface{})
- func (e *Entry) Warn(args ...interface{})
- func (e *Entry) Warningf(format string, args ...interface{})
- func (e *Entry) WithField(key string, value interface{}) *Entry
- func (e *Entry) WithFields(fields Fields) *Entry
- type Fields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddContext ¶
func AddContext(key string, value interface{})
AddContext adds another context to the logger
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf is the wrapper for Logrus Debugf()
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf is the wrapper for Logrus Errorf()
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf is the wrapper for Logris Fatalf()
func SetFormatter ¶
func SetFormatter(formatter string)
SetFormatter sets the formatter to be used, either "json" or "text"
func SetLogrusFormatter ¶
SetLogrusFormatter sets the logrus formatter to be used
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry contains a Logrus entry
func WithFields ¶
WithFields adds more Fields to the logger entry context
func (*Entry) Debug ¶
func (e *Entry) Debug(args ...interface{})
Debug is the wrapper for Logrus Debug()
func (*Entry) Error ¶
func (e *Entry) Error(args ...interface{})
Error is the wrapper for Logrus Error()
func (*Entry) Fatal ¶
func (e *Entry) Fatal(args ...interface{})
Fatal is the wrapper for Logrus Fatal()
func (*Entry) Info ¶
func (e *Entry) Info(args ...interface{})
Info is the wrapper for Logrus Info()
func (*Entry) Warn ¶
func (e *Entry) Warn(args ...interface{})
Warn is the wrapper for Logrus Warn()
func (*Entry) WithFields ¶
WithFields adds more Fields to the Logrus entry context