Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketCapacity

func BucketCapacity() uint32

BucketCapacity returns the system wide LogEntry buffering capacity for any log handler

func Disable

func Disable()

Disable disables the logging manager globally

func DisableStacktrace

func DisableStacktrace()

DisableStacktrace disables using stacktrace in logging

func Enable

func Enable()

Enable enables the logging manager globally

func EnableStacktrace

func EnableStacktrace()

EnableStacktrace enables using stacktrace in logging

func Enabled

func Enabled() bool

Enabled function is used to get if the global logging manager is enabled

func Log

func Log(entry *LogEntry)

Log lets the given entry to be processes by the handler chain

func LogError

func LogError(e error, args map[string]interface{})

LogError is used to log the given error by log manager

func LogFatal

func LogFatal(e error, args map[string]interface{})

LogFatal is used to log the given error as fatal by log manager

func LogMessage

func LogMessage(message string, args map[string]interface{})

LogMessage is used to log the given message by log manager

func LogWarning

func LogWarning(message string, args map[string]interface{})

LogWarning is used to log the message as warning by log manager

func RegisterHandler

func RegisterHandler(handler LogHandler)

RegisterHandler adds the handler into the logging chain

func RegisterHandlerWithName

func RegisterHandlerWithName(name string, handler LogHandler)

RegisterHandlerWithName adds the handler into the logging chain with the given name

func SetBucketCapacity

func SetBucketCapacity(cap uint32)

SetBucketCapacity sets the system wide LogEntry buffering capacity for any log handler

func StacktraceEnabled

func StacktraceEnabled() bool

StacktraceEnabled function is used to get if the global stacktrace usage is enabled

func UnregisterHandler

func UnregisterHandler(name string)

UnregisterHandler removes the handler from the logging chain

Types

type ConsoleLogHandler

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

ConsoleLogHandler is used to push the log entry to console

func (*ConsoleLogHandler) Disable

func (handler *ConsoleLogHandler) Disable()

Disable deactivates the handler

func (*ConsoleLogHandler) Enable

func (handler *ConsoleLogHandler) Enable()

Enable activates the handler

func (*ConsoleLogHandler) Enabled

func (handler *ConsoleLogHandler) Enabled() bool

Enabled returns if the handler is active

func (*ConsoleLogHandler) Format

func (handler *ConsoleLogHandler) Format() LogFormat

Format gives the format that will be used by the handler

func (*ConsoleLogHandler) Level

func (handler *ConsoleLogHandler) Level() LogLevel

Level gives if the pushed entry should be logged by the handler

func (*ConsoleLogHandler) Name

func (handler *ConsoleLogHandler) Name() string

Name returns the name of the handler used for registration

func (*ConsoleLogHandler) Process

func (handler *ConsoleLogHandler) Process(entry interface{})

Process evaluates the given entry

func (*ConsoleLogHandler) QueueLen

func (handler *ConsoleLogHandler) QueueLen() int

QueueLen gives the queue length that will be used when the entry is queued

type LogEntry

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

LogEntry is used to send the information to handlers

func NewErrorLogEntry

func NewErrorLogEntry(err error, args map[string]interface{}) *LogEntry

NewErrorLogEntry creates a new log entry with error level which will be send to handlers

func NewFatalLogEntry

func NewFatalLogEntry(err error, args map[string]interface{}) *LogEntry

NewFatalLogEntry creates a new log entry with fatal level which will be send to handlers

func NewInfoLogEntry

func NewInfoLogEntry(message string, args map[string]interface{}) *LogEntry

NewInfoLogEntry creates a new log entry with info level which will be send to handlers

func NewWarningLogEntry

func NewWarningLogEntry(message string, args map[string]interface{}) *LogEntry

NewWarningLogEntry creates a new log entry with warning level which will be send to handlers

func (*LogEntry) Args

func (entry *LogEntry) Args() map[string]interface{}

Args returns the arguments of the entry

func (*LogEntry) Duration

func (entry *LogEntry) Duration() time.Duration

Duration returns the measured duration (time passed between StartWatch and StopWatch) of the entry

func (*LogEntry) ID

func (entry *LogEntry) ID() string

ID returns the id of the entry

func (*LogEntry) Level

func (entry *LogEntry) Level() LogLevel

Level returns the log type of the entry

func (*LogEntry) Message

func (entry *LogEntry) Message() string

Message returns the message of the entry

func (*LogEntry) Stack

func (entry *LogEntry) Stack() string

Stack returns the stack trace of the entry

func (*LogEntry) StartWatch

func (entry *LogEntry) StartWatch()

StartWatch starts timer to measure the time passed

func (*LogEntry) StopWatch

func (entry *LogEntry) StopWatch()

StopWatch stops the timer to measure the time passed

func (*LogEntry) Time

func (entry *LogEntry) Time() time.Time

Time returns the creation time of the entry

func (*LogEntry) ToJSON

func (entry *LogEntry) ToJSON() []byte

ToJSON returns the JSON formatted entry as byte array

func (*LogEntry) ToText

func (entry *LogEntry) ToText() []byte

ToJSON returns the text line formatted entry as byte array

type LogFormat

type LogFormat byte

LogFormat defines the format of the log that will be processed by a handler

const (
	// TextFormat represents that the hadler will accept the log entry in text line format as input
	TextFormat LogFormat = iota
	// JSONFormat represents that the hadler will accept the log entry in JSON format as input
	JSONFormat
	// CustomFormat represents that the hadler will accept the log entry as input and will format the entry by it self
	CustomFormat
)

type LogHandler

type LogHandler interface {
	// Name returns the name of the handler used for registration
	Name() string
	// Enable activates the handler
	Enable()
	// Enable deactivates the handler
	Disable()
	// Enabled returns if the handler is active
	Enabled() bool
	// Level gives if the pushed entry should be logged by the handler
	Level() LogLevel
	// Format gives the format that will be used by the handler
	Format() LogFormat
	// QueueLen gives the queue length that will be used when the entry is queued
	QueueLen() int
	// Process evaluates the given entry
	Process(entry interface{})
}

LogHandler is the interface which handles log writes to different destinations

type LogLevel

type LogLevel byte

LogLevel is used to inform the system about the given message type

const (
	// LevelInfo is used if the message is an information
	LevelInfo LogLevel = 1
	// LevelWarning is used if the message is a warning
	LevelWarning LogLevel = 2
	// LevelError is used if the message is an error
	LevelError LogLevel = 4
	// LevelFatal is used if the message is a fatal error
	LevelFatal LogLevel = 8
	// AllLogLevels is used to push a logentry to a handler with overriding its LoggingType
	AllLogLevels = LevelInfo | LevelWarning | LevelError | LevelFatal
)

func (LogLevel) Has

func (l LogLevel) Has(l2 LogLevel) bool

Has checks if lt includes lt2

func (LogLevel) String

func (l LogLevel) String() string