Documentation
Index ¶
- func BucketCapacity() uint32
- func Disable()
- func DisableStacktrace()
- func Enable()
- func EnableStacktrace()
- func Enabled() bool
- func Log(entry *LogEntry)
- func LogError(e error, args map[string]interface{})
- func LogFatal(e error, args map[string]interface{})
- func LogMessage(message string, args map[string]interface{})
- func LogWarning(message string, args map[string]interface{})
- func RegisterHandler(handler LogHandler)
- func RegisterHandlerWithName(name string, handler LogHandler)
- func SetBucketCapacity(cap uint32)
- func StacktraceEnabled() bool
- func UnregisterHandler(name string)
- type ConsoleLogHandler
- func (handler *ConsoleLogHandler) Disable()
- func (handler *ConsoleLogHandler) Enable()
- func (handler *ConsoleLogHandler) Enabled() bool
- func (handler *ConsoleLogHandler) Format() LogFormat
- func (handler *ConsoleLogHandler) Level() LogLevel
- func (handler *ConsoleLogHandler) Name() string
- func (handler *ConsoleLogHandler) Process(entry interface{})
- func (handler *ConsoleLogHandler) QueueLen() int
- type LogEntry
- func (entry *LogEntry) Args() map[string]interface{}
- func (entry *LogEntry) Duration() time.Duration
- func (entry *LogEntry) ID() string
- func (entry *LogEntry) Level() LogLevel
- func (entry *LogEntry) Message() string
- func (entry *LogEntry) Stack() string
- func (entry *LogEntry) StartWatch()
- func (entry *LogEntry) StopWatch()
- func (entry *LogEntry) Time() time.Time
- func (entry *LogEntry) ToJSON() []byte
- func (entry *LogEntry) ToText() []byte
- type LogFormat
- type LogHandler
- type LogLevel
Constants ¶
Variables ¶
Functions ¶
func BucketCapacity ¶
func BucketCapacity() uint32
BucketCapacity returns the system wide LogEntry buffering capacity for any log handler
func DisableStacktrace ¶
func DisableStacktrace()
DisableStacktrace disables using stacktrace in logging
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 LogMessage ¶
LogMessage is used to log the given message by log manager
func LogWarning ¶
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 ¶
NewErrorLogEntry creates a new log entry with error level which will be send to handlers
func NewFatalLogEntry ¶
NewFatalLogEntry creates a new log entry with fatal level which will be send to handlers
func NewInfoLogEntry ¶
NewInfoLogEntry creates a new log entry with info level which will be send to handlers
func NewWarningLogEntry ¶
NewWarningLogEntry creates a new log entry with warning level which will be send to handlers
func (*LogEntry) Duration ¶
Duration returns the measured duration (time passed between StartWatch and StopWatch) 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
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 )