Documentation ¶
Overview ¶
Package logger is a wrapper around logrus that logs in a structured JSON format and provides additional context keys. To use this library, first call `logger.Init("info")` or logger.InitWithRollbar(...), then call logging functions e.g. `logger.Infoln("message")`. You can also use CaptureDefault() to capture output that would go to the default logger (e.g. from dependencies).
Index ¶
- func CaptureDefault()
- func Debug(args ...interface{})
- func Debugf(format string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func Errorf(format string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Fatalln(args ...interface{})
- func GetCapturedLogger() *log.Logger
- func Go(f func())
- func Info(args ...interface{})
- func Infof(format string, args ...interface{})
- func Infoln(args ...interface{})
- func Init(level string)
- func InitWithRollbar(level, rollbarToken, rollbarEnv string)
- func LogPanic()
- func NewRollbarHook(token string, env string, levels []logrus.Level) logrus.Hook
- func Panic(args ...interface{})
- func Panicf(format string, args ...interface{})
- func Panicln(args ...interface{})
- func Print(args ...interface{})
- func Printf(format string, args ...interface{})
- func Println(args ...interface{})
- func Wait()
- func Warn(args ...interface{})
- func Warnf(format string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(format string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- type Entry
- func (entry *Entry) Debug(args ...interface{})
- func (entry *Entry) Debugf(format string, args ...interface{})
- func (entry *Entry) Debugln(args ...interface{})
- func (entry *Entry) Error(args ...interface{})
- func (entry *Entry) Errorf(format string, args ...interface{})
- func (entry *Entry) Errorln(args ...interface{})
- func (entry *Entry) Fatal(args ...interface{})
- func (entry *Entry) Fatalf(format string, args ...interface{})
- func (entry *Entry) Fatalln(args ...interface{})
- func (entry *Entry) Info(args ...interface{})
- func (entry *Entry) Infof(format string, args ...interface{})
- func (entry *Entry) Infoln(args ...interface{})
- func (entry *Entry) Panic(args ...interface{})
- func (entry *Entry) Panicf(format string, args ...interface{})
- func (entry *Entry) Panicln(args ...interface{})
- func (entry *Entry) Print(args ...interface{})
- func (entry *Entry) Printf(format string, args ...interface{})
- func (entry *Entry) Println(args ...interface{})
- func (entry *Entry) Warn(args ...interface{})
- func (entry *Entry) Warnf(format string, args ...interface{})
- func (entry *Entry) Warning(args ...interface{})
- func (entry *Entry) Warningf(format string, args ...interface{})
- func (entry *Entry) Warningln(args ...interface{})
- func (entry *Entry) Warnln(args ...interface{})
- func (entry *Entry) WithError(err error) *Entry
- func (entry *Entry) WithField(key string, value interface{}) *Entry
- func (entry *Entry) WithFields(fields logrus.Fields) *Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureDefault ¶
func CaptureDefault()
CaptureDefault causes all outupt to the default logger to be redirected to the logrus logger at the Warn level.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf logs the formatted string at Debug level.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs the formatted string at Error level.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs the formatted string at Error level and exits.
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs the args at the Error level and exits.
func GetCapturedLogger ¶
GetCapturedLogger returns a *log.Logger with its output redirected to the logrus logger at the Warn level.
func Go ¶
func Go(f func())
Go spawns a goroutine like `go`, but captures and logs any panics that happen in them. Turn `go g()` into `logger.Go(func(){g()})
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs the formatted string at Info level.
func InitWithRollbar ¶
func InitWithRollbar(level, rollbarToken, rollbarEnv string)
InitWithRollbar sets up logging at the given level, and sends log message of level panic, fatal, and error to rollbar. If rollbarToken isn't properly set, it will initialize the logrus logger without rollbar and move on, logging a message once the error response comes back from rollbar. In your main shutdown code, be sure to call rollbar.Wait() to guarantee late errors get sent to rollbar.
func LogPanic ¶
func LogPanic()
LogPanic catches any raw panics and logs them. Triggers another panic.
func NewRollbarHook ¶
NewRollbarHook creates a Rollbar hook for logrus.
func Panicf ¶
func Panicf(format string, args ...interface{})
Panicf logs the formatted string at Error level and panics.
func Panicln ¶
func Panicln(args ...interface{})
Panicln logs the args at the Error level and panics.
func Printf ¶
func Printf(format string, args ...interface{})
Printf logs the formatted string at Info level.
func Warnf ¶
func Warnf(format string, args ...interface{})
Warnf logs the formatted string at Warn level.
Types ¶
type Entry ¶
func WithFields ¶
WithFields creates an Entry with the given fields added.
func (*Entry) Debug ¶
func (entry *Entry) Debug(args ...interface{})
Debug logs the args at the Debug level.
func (*Entry) Debugln ¶
func (entry *Entry) Debugln(args ...interface{})
Debugln logs the args at the Debug level.
func (*Entry) Error ¶
func (entry *Entry) Error(args ...interface{})
Error logs the args at the Error level.
func (*Entry) Errorln ¶
func (entry *Entry) Errorln(args ...interface{})
Errorln logs the args at the Error level.
func (*Entry) Fatal ¶
func (entry *Entry) Fatal(args ...interface{})
Fatal logs the args at the Error level and exits.
func (*Entry) Fatalln ¶
func (entry *Entry) Fatalln(args ...interface{})
Fatalln logs the args at the Error level and exits.
func (*Entry) Info ¶
func (entry *Entry) Info(args ...interface{})
Info logs the args at the Info level.
func (*Entry) Infoln ¶
func (entry *Entry) Infoln(args ...interface{})
Infoln logs the args at the Info level.
func (*Entry) Panic ¶
func (entry *Entry) Panic(args ...interface{})
Panic logs the args at the Error level and panics.
func (*Entry) Panicln ¶
func (entry *Entry) Panicln(args ...interface{})
Panicln logs the args at the Error level and panics.
func (*Entry) Print ¶
func (entry *Entry) Print(args ...interface{})
Print logs the args at the Info level.
func (*Entry) Println ¶
func (entry *Entry) Println(args ...interface{})
Println logs the args at the Info level.
func (*Entry) Warn ¶
func (entry *Entry) Warn(args ...interface{})
Warn logs the args at the Warn level.
func (*Entry) Warning ¶
func (entry *Entry) Warning(args ...interface{})
Warning logs the args at the Warn level.
func (*Entry) Warningln ¶
func (entry *Entry) Warningln(args ...interface{})
Warningln logs the args at the Warn level.