Documentation ¶
Overview ¶
Package seelog implements logging functionality with flexible dispatching, filtering, and formatting.
Index ¶
- Constants
- Variables
- func Critical(format string, params ...interface{})
- func Debug(format string, params ...interface{})
- func Error(format string, params ...interface{})
- func Flush()
- func Info(format string, params ...interface{})
- func ReplaceLogger(logger LoggerInterface) error
- func Trace(format string, params ...interface{})
- func UseLogger(logger LoggerInterface) error
- func Warn(format string, params ...interface{})
- type LogLevel
- type LoggerInterface
- func LoggerFromConfigAsBytes(data []byte) (LoggerInterface, error)
- func LoggerFromConfigAsFile(fileName string) (LoggerInterface, error)
- func LoggerFromConfigAsString(data string) (LoggerInterface, error)
- func LoggerFromWriterWithMinLevel(output io.Writer, minLevel LogLevel) (LoggerInterface, error)
Constants ¶
const ( SeelogConfigId = "seelog" OutputsId = "outputs" FormatsId = "formats" MinLevelId = "minlevel" MaxLevelId = "maxlevel" LevelsId = "levels" ExceptionsId = "exceptions" ExceptionId = "exception" FuncPatternId = "funcpattern" FilePatternId = "filepattern" FormatId = "format" FormatAttrId = "format" FormatKeyAttrId = "id" OutputFormatId = "formatid" FilePathId = "path" FileWriterId = "file" SmtpWriterId = "smtp" SenderAddressId = "senderaddress" SenderNameId = "sendername" RecipientId = "recipient" AddressId = "address" HostNameId = "hostname" HostPortId = "hostport" UserNameId = "username" UserPassId = "password" SpliterDispatcherId = "splitter" ConsoleWriterId = "console" FilterDispatcherId = "filter" FilterLevelsAttrId = "levels" RollingFileWriterId = "rollingfile" RollingFileTypeAttr = "type" RollingFilePathAttr = "filename" RollingFileMaxSizeAttr = "maxsize" RollingFileMaxRollsAttr = "maxrolls" RollingFileDataPatternAttr = "datepattern" BufferedSizeAttr = "size" BufferedFlushPeriodAttr = "flushperiod" LoggerTypeFromStringAttr = "type" AsyncLoggerIntervalAttr = "asyncinterval" )
const ( TraceLvl = iota DebugLvl InfoLvl WarnLvl ErrorLvl CriticalLvl Off )
Log levels
const ( TraceStr = "trace" DebugStr = "debug" InfoStr = "info" WarnStr = "warn" ErrorStr = "error" CriticalStr = "critical" OffStr = "off" )
Log level string representations (used in configuration files)
const ( VerbSymbol = '%' VerbSymbolString = "%" VerbParameterStart = '(' VerbParameterEnd = ')' DateDefaultFormat = "2006-01-02" TimeFormat = "15:04:05" )
const ( Size = iota Date )
const (
AsyncloggerTypeFromStringStr = "asyncloop"
)
const (
DefaultloggerTypeFromString = asyncLooploggerTypeFromString
)
const (
MaxQueueSize = 10000
)
Variables ¶
var Defaultformatter *formatter
Functions ¶
func Critical ¶
func Critical(format string, params ...interface{})
Critical formats message according to format specifier and writes to default logger with log level = Critical
func Debug ¶
func Debug(format string, params ...interface{})
Debug formats message according to format specifier and writes to default logger with log level = Debug
func Error ¶
func Error(format string, params ...interface{})
Error formats message according to format specifier and writes to default logger with log level = Error
func Flush ¶
func Flush()
Flush performs all cleanup, flushes all queued messages, etc. Call this method when your app is going to shut down not to lose any log messages.
func Info ¶
func Info(format string, params ...interface{})
Info formats message according to format specifier and writes to default logger with log level = Info
func ReplaceLogger ¶
func ReplaceLogger(logger LoggerInterface) error
Acts as UseLogger but the logger that was previously used would be disposed (except Default and Disabled loggers).
func Trace ¶
func Trace(format string, params ...interface{})
Trace formats message according to format specifier and writes to default logger with log level = Trace
func UseLogger ¶
func UseLogger(logger LoggerInterface) error
UseConfig uses the given logger for all Trace/Debug/... funcs.
Types ¶
type LogLevel ¶
type LogLevel uint8
Log level type
func LogLevelFromString ¶
LogLevelFromString parses a string and returns a corresponding log level, if sucessfull.
type LoggerInterface ¶
type LoggerInterface interface { Trace(format string, params ...interface{}) Debug(format string, params ...interface{}) Info(format string, params ...interface{}) Warn(format string, params ...interface{}) Error(format string, params ...interface{}) Critical(format string, params ...interface{}) Close() Flush() Closed() bool // contains filtered or unexported methods }
LoggerInterface represents structs capable of logging Seelog messages
var Current LoggerInterface
var Default LoggerInterface
var Disabled LoggerInterface
func LoggerFromConfigAsBytes ¶
func LoggerFromConfigAsBytes(data []byte) (LoggerInterface, error)
LoggerFromConfigAsBytes creates a logger with config from bytes stream. Bytes should contain valid seelog xml.
func LoggerFromConfigAsFile ¶
func LoggerFromConfigAsFile(fileName string) (LoggerInterface, error)
LoggerFromConfigAsFile creates logger with config from file. File should contain valid seelog xml.
func LoggerFromConfigAsString ¶
func LoggerFromConfigAsString(data string) (LoggerInterface, error)
LoggerFromConfigAsString creates a logger with config from a string. String should contain valid seelog xml.
func LoggerFromWriterWithMinLevel ¶
func LoggerFromWriterWithMinLevel(output io.Writer, minLevel LogLevel) (LoggerInterface, error)
LoggerFromWriterWithMinLevel creates a simple logger for usage with non-Seelog systems. Creates logger that writes to output with minimal level = minLevel.
Source Files ¶
- behavior_asynclogger.go
- behavior_asynclooplogger.go
- behavior_asynctimerlogger.go
- behavior_synclogger.go
- cfg_config.go
- cfg_logconfig.go
- cfg_parser.go
- common_closer.go
- common_constraints.go
- common_context.go
- common_exception.go
- common_flusher.go
- common_loglevel.go
- dispatch_dispatcher.go
- dispatch_filterdispatcher.go
- dispatch_splitdispatcher.go
- format.go
- internals_byteverifiers.go
- internals_fswrapper.go
- internals_test_fswrapper.go
- internals_testfswrapper.go
- internals_testhelpers.go
- internals_xmlnode.go
- log.go
- logger.go
- writers_bufferedwriter.go
- writers_consolewriter.go
- writers_filewriter.go
- writers_formattedwriter.go
- writers_rollingfilewriter.go
- writers_smtpwriter.go