logger

package module
v0.0.0-...-d342af0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: NCSA Imports: 13 Imported by: 154

README

Logger Build Status

Config

example

logger:
  level: debug
  hooks:
    - kenisis
    - syslog
    - logz
    - graylog
    - airbrake
logz:
  token: LOGZ_TOKEN
graylog:
   address: ...
   port: 12201
airbrake:
   id: ...
   api_key: ...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Config = &loggerConfig{
		done: make(chan struct{}),
	}
)

Functions

func AddHook

func AddHook(hook logrus.Hook)

AddHook adds a hook to the standard logrusger hooks.

func Caller

func Caller() (file string, line int)

returns file and line two stack frames above its invocation

func Debug

func Debug(args ...interface{})

Debug logruss a message at level Debug on the standard logrusger.

func Debugf

func Debugf(format string, args ...interface{})

Debugf logruss a message at level Debug on the standard logrusger.

func Debugln

func Debugln(args ...interface{})

Debugln logruss a message at level Debug on the standard logrusger.

func Decorate

func Decorate(logger *logrus.Entry) func() *logrus.Entry

Decorate appends line, file and function context to the logger and returns a function to call before each log

func Error

func Error(args ...interface{})

Error logruss a message at level Error on the standard logrusger.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logruss a message at level Error on the standard logrusger.

func Errorln

func Errorln(args ...interface{})

Errorln logruss a message at level Error on the standard logrusger.

func Fatal

func Fatal(args ...interface{})

Fatal logruss a message at level Fatal on the standard logrusger.

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf logruss a message at level Fatal on the standard logrusger.

func Fatalln

func Fatalln(args ...interface{})

Fatalln logruss a message at level Fatal on the standard logrusger.

func GetHook

func GetHook(name string) (logrus.Hook, error)

func GetLevel

func GetLevel() logrus.Level

GetLevel returns the standard logrusger level.

func Info

func Info(args ...interface{})

Info logruss a message at level Info on the standard logrusger.

func Infof

func Infof(format string, args ...interface{})

Infof logruss a message at level Info on the standard logrusger.

func Infoln

func Infoln(args ...interface{})

Infoln logruss a message at level Info on the standard logrusger.

func Log

func Log() *logrus.Entry

Log appends line, file and function context to the logger

func Panic

func Panic(args ...interface{})

Panic logruss a message at level Panic on the standard logrusger.

func Panicf

func Panicf(format string, args ...interface{})

Panicf logruss a message at level Panic on the standard logrusger.

func Panicln

func Panicln(args ...interface{})

Panicln logruss a message at level Panic on the standard logrusger.

func Print

func Print(args ...interface{})

Print logruss a message at level Info on the standard logrusger.

func Printf

func Printf(format string, args ...interface{})

Printf logruss a message at level Info on the standard logrusger.

func Println

func Println(args ...interface{})

Println logruss a message at level Info on the standard logrusger.

func RegisterHook

func RegisterHook(name string, imp logrus.Hook)

func SetFormatter

func SetFormatter(formatter logrus.Formatter)

SetFormatter sets the standard logrusger formatter.

func SetLevel

func SetLevel(level logrus.Level)

SetLevel sets the standard logrusger level.

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets the standard logrusger output.

func UsingHook

func UsingHook(s string) bool

func Warn

func Warn(args ...interface{})

Warn logruss a message at level Warn on the standard logrusger.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logruss a message at level Warn on the standard logrusger.

func Warning

func Warning(args ...interface{})

Warning logruss a message at level Warn on the standard logrusger.

func Warningf

func Warningf(format string, args ...interface{})

Warningf logruss a message at level Warn on the standard logrusger.

func Warningln

func Warningln(args ...interface{})

Warningln logruss a message at level Warn on the standard logrusger.

func Warnln

func Warnln(args ...interface{})

Warnln logruss a message at level Warn on the standard logrusger.

func WithError

func WithError(err error) *logrus.Entry

WithError creates an entry from the standard logrusger and adds an error to it, using the value defined in ErrorKey as key.

func WithField

func WithField(key string, value interface{}) *logrus.Entry

WithField creates an entry from the standard logrusger and adds a field to it. If you want multiple fields, use `WithFields`.

Note that it doesn't logrus until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

WithFields creates an entry from the standard logrusger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.

Note that it doesn't logrus until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.

Types

type Logger

type Logger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}

func New

func New() *Logger

Creates a new logrusger. Configuration should be set by changing `Formatter`, `Out` and `Hooks` directly on the default logrusger instance. You can also just instantiate your own:

var logrus = &Logger{
  Out: os.Stderr,
  Formatter: new(JSONFormatter),
  Hooks: make(LevelHooks),
  Level: logrusrus.DebugLevel,
}

It's recommended to make this a global instance called `logrus`.

func StandardLogger

func StandardLogger() *Logger

type MutexWrap

type MutexWrap struct {
	// contains filtered or unexported fields
}

func (*MutexWrap) Disable

func (mw *MutexWrap) Disable()

func (*MutexWrap) Lock

func (mw *MutexWrap) Lock()

func (*MutexWrap) Unlock

func (mw *MutexWrap) Unlock()

type StackHook

type StackHook struct {
	// Set levels to CallerLevels for which "caller" value may be set,
	// providing a single frame of stack.
	CallerLevels []logrus.Level

	// Set levels to StackLevels for which "stack" value may be set,
	// providing the full stack (minus logrus).
	StackLevels []logrus.Level
}

StackHook is an implementation of logrus.Hook interface.

func NewStackHook

func NewStackHook(callerLevels []logrus.Level, stackLevels []logrus.Level) StackHook

NewHook is the initializer for StackHook{} (implementing logrus.Hook). Set levels to callerLevels for which "caller" value may be set, providing a single frame of stack. Set levels to stackLevels for which "stack" value may be set, providing the full stack (minus logrus).

func StandardStackHook

func StandardStackHook() StackHook

StackHook is a convenience initializer for StackHook{} with default args.

func (StackHook) Fire

func (hook StackHook) Fire(entry *logrus.Entry) error

Fire is called by logrus when something is logged.

func (StackHook) Levels

func (hook StackHook) Levels() []logrus.Level

Levels provides the levels to filter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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