Documentation

Index

Constants

View Source
const (
	// OffLevel disables logging.
	OffLevel = "off"
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel = "error"
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = "warn"
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel = "info"
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = "debug"
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel = "trace"
)

Variables

This section is empty.

Functions

func GetLogLevel

func GetLogLevel(logLevel string) (int, error)

GetLogLevel returns the corresponding log level with the given string if it exists, otherwise returns an error.

Types

type DefaultLogger

type DefaultLogger struct {
	*log.Logger
	Level int
}

DefaultLogger has Go's built in log embedded in it. It adds level logging. To set the logging level, one should use the LoggingLevel property. For example to set it to debug level:

config.SetProperty(property.LoggingLevel.Name(), logger.DebugLevel)

If loggerConfig.SetLogger() method is called, the LoggingLevel property will not be used.

func New

func New() *DefaultLogger

New returns a Default Logger with defaultLogLevel. To set the logging level, one should use the LoggingLevel property. For example to set it to debug level:

config.SetProperty(property.LoggingLevel.Name(), logger.DebugLevel)

If loggerConfig.SetLogger() method is called, the LoggingLevel property will not be used.

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(args ...interface{})

Debug logs the given arguments at debug level if the level is greater than or equal to debug level.

func (*DefaultLogger) Error

func (l *DefaultLogger) Error(args ...interface{})

Error logs the given arguments at error level if the level is greater than or equal to error level.

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(args ...interface{})

Info logs the given arguments at info level if the level is greater than or equal to info level.

func (*DefaultLogger) Trace

func (l *DefaultLogger) Trace(args ...interface{})

Trace logs the given arguments at trace level if the level is greater than or equal to trace level.

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(args ...interface{})

Warn logs the given arguments at warn level if the level is greater than or equal to warn level.

type Logger

type Logger interface {
	// Debug logs the given args at debug level.
	Debug(args ...interface{})
	// Trace logs the given args at trace level.
	Trace(args ...interface{})
	// Info logs the given args at info level.
	Info(args ...interface{})
	// Warn logs the given args at warn level.
	Warn(args ...interface{})
	// Error logs the given args at error level.
	Error(args ...interface{})
}

Logger is the interface that is used by client for logging.