logger

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(newLogger GenericLogger)

SetLogger sets the internal logger to the one provided

Types

type GenericContext

type GenericContext interface {
	Field(key string, val interface{}) GenericContext

	// Actually log the built up log line with the message
	Log(msg string)
}

GenericContext provides a way to add fields to a log event

func Debug

func Debug() GenericContext

Debug calls the debug method of the registered logger

func Error

func Error() GenericContext

Error calls the error method of the registered logger

func Info

func Info() GenericContext

Info calls the info method of the registered logger

func Warn

func Warn() GenericContext

Warn calls the warn method of the registered logger

type GenericLogger

type GenericLogger interface {
	// Base log types
	Debug() GenericContext
	Info() GenericContext
	Warn() GenericContext
	Error() GenericContext

	// Add context like logger.With(NewContext().Field("test", "val"))
	With(ctx GenericContext) GenericLogger
}

GenericLogger is the logger interface that legion uses, you can plug in your own logger as long as your logger implements this interface.

func GetLogger

func GetLogger() GenericLogger

GetLogger returns the internal logger

func With

With calls the with method of the registered logger, and returns a logger with those fields attached by default

type ZeroLogContext

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

ZeroLogContext meets the interface type and provides context to a log event

func (*ZeroLogContext) Field

func (zlc *ZeroLogContext) Field(key string, val interface{}) GenericContext

Field appends a field to the context

func (*ZeroLogContext) Log

func (zlc *ZeroLogContext) Log(msg string)

Log prints the compiled log

type ZeroLogger

type ZeroLogger struct {
	Logger zerolog.Logger
}

ZeroLogger is a wrapper around zerolog so it can implement our interface

func NewZeroLogger

func NewZeroLogger() *ZeroLogger

NewZeroLogger returns a new ZeroLogger

func (*ZeroLogger) Debug

func (zl *ZeroLogger) Debug() GenericContext

Debug calls the debug method of the registered logger

func (*ZeroLogger) Error

func (zl *ZeroLogger) Error() GenericContext

Error calls the error method of the registered logger

func (*ZeroLogger) Info

func (zl *ZeroLogger) Info() GenericContext

Info calls the info method of the registered logger

func (*ZeroLogger) Warn

func (zl *ZeroLogger) Warn() GenericContext

Warn calls the warn method of the registered logger

func (*ZeroLogger) With

With appends the context to a new logger and returns it

Jump to

Keyboard shortcuts

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