Documentation ¶
Index ¶
- Constants
- func FormatLog(log *Log) string
- func FormatLogWithTimezone(log *Log) string
- func GetFormatLogFunc() func(log *Log) string
- func IgnoreThisFilenameToo(fn string)
- func SetFormatLogFunc(f func(log *Log) string)
- func SetMaxLogSize(size int)
- func TurboLevelFilter(threshold Level) func(Level, string, ...interface{}) bool
- type Appender
- type Context
- type ErrorCode
- type ErrorWithCode
- type FileAppender
- type Filter
- type FilterAppender
- type Level
- type Log
- type Logger
- func (self *Logger) Errorf(level Level, messageFmt string, args ...interface{}) error
- func (self *Logger) ErrorfWithContext(level Level, messageFmt string, context *Context, args ...interface{}) error
- func (self *Logger) ErrorfWithErrorCodeAndContext(level Level, errorCode ErrorCode, messageFmt string, context *Context, ...) error
- func (self *Logger) Flush() (errors []error)
- func (self *Logger) Logf(level Level, messageFmt string, args ...interface{}) (*Log, []error)
- func (self *Logger) LogfWithContext(level Level, messageFmt string, context *Context, args ...interface{}) (*Log, []error)
- func (self *Logger) LogfWithErrorCodeAndContext(level Level, errorCode ErrorCode, messageFmt string, context *Context, ...) (*Log, []error)
- func (self *Logger) Stackf(level Level, stackErr error, messageFmt string, args ...interface{}) (*Log, []error)
- func (self *Logger) StackfWithContext(level Level, stackErr error, messageFmt string, context *Context, ...) (*Log, []error)
- func (self *Logger) StackfWithErrorCodeAndContext(level Level, errorCode ErrorCode, stackErr error, messageFmt string, ...) (*Log, []error)
- type StackError
- type StringAppender
- type StringWriter
- type TurboFilter
- type UnknownLevelError
Constants ¶
const MinimumMaxLogSizeThreshold = 100
MaxLogSize values below this threshold are effectively ignored
const NoErrorCode = 0
Variables ¶
This section is empty.
Functions ¶
func FormatLogWithTimezone ¶
func GetFormatLogFunc ¶
func IgnoreThisFilenameToo ¶
func IgnoreThisFilenameToo(fn string)
Add a file to the list of file names that slogger will skip when it identifies the source of a message. This is useful if you have a logging library built on top of slogger. If you IgnoreThisFilenameToo(...) on the files of that library, logging messages will be marked as coming from your code that calls your library, rather than from your library.
func SetFormatLogFunc ¶
func SetMaxLogSize ¶
func SetMaxLogSize(size int)
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() *Context
type ErrorWithCode ¶
func (ErrorWithCode) Error ¶
func (e ErrorWithCode) Error() string
type FileAppender ¶
type FileAppender struct {
StringWriter
}
func DevNullAppender ¶
func DevNullAppender() (*FileAppender, error)
func StdErrAppender ¶
func StdErrAppender() *FileAppender
func StdOutAppender ¶
func StdOutAppender() *FileAppender
func (FileAppender) Append ¶
func (self FileAppender) Append(log *Log) error
func (FileAppender) Flush ¶
func (self FileAppender) Flush() error
type FilterAppender ¶
func LevelFilter ¶
func LevelFilter(threshold Level, appender Appender) *FilterAppender
func (*FilterAppender) Append ¶
func (self *FilterAppender) Append(log *Log) error
func (*FilterAppender) Flush ¶
func (self *FilterAppender) Flush() error
type Level ¶
type Level uint8
The level is in an order such that the expressions `level < WARN`, `level >= INFO` have intuitive meaning.
type Log ¶
type Log struct { Prefix string Level Level ErrorCode ErrorCode Filename string FuncName string Line int Timestamp time.Time MessageFmt string Args []interface{} Context *Context }
func SimpleLogStrippingDirs ¶
type Logger ¶
type Logger struct { Prefix string Appenders []Appender StripDirs int TurboFilters []TurboFilter }
func (*Logger) ErrorfWithContext ¶
func (*Logger) ErrorfWithErrorCodeAndContext ¶
func (*Logger) Logf ¶
Log a message and a level to a logger instance. This returns a pointer to a Log and a slice of errors that were gathered from every Appender (nil errors included), or nil and an empty error slice if any turbo filter condition was not satisfied causing an early exit.
func (*Logger) LogfWithContext ¶
func (*Logger) LogfWithErrorCodeAndContext ¶
func (*Logger) Stackf ¶
func (self *Logger) Stackf(level Level, stackErr error, messageFmt string, args ...interface{}) (*Log, []error)
Stackf is designed to work in tandem with `NewStackError`. This function is similar to `Logf`, but takes a `stackErr` parameter. `stackErr` is expected to be of type StackError, but does not have to be.
func (*Logger) StackfWithContext ¶
type StackError ¶
func NewStackError ¶
func NewStackError(messageFmt string, args ...interface{}) *StackError
func (*StackError) Error ¶
func (self *StackError) Error() string
type StringAppender ¶
func NewStringAppender ¶
func NewStringAppender(buffer *bytes.Buffer) *StringAppender
func (StringAppender) Append ¶
func (self StringAppender) Append(log *Log) error
func (StringAppender) Flush ¶
func (self StringAppender) Flush() error
type StringWriter ¶
type TurboFilter ¶
enables level-filtering before a Log entry is created, avoiding the runtime.Caller invocation return true if filter evaluation should continue
type UnknownLevelError ¶
type UnknownLevelError struct {
// contains filtered or unexported fields
}
func (UnknownLevelError) Error ¶
func (self UnknownLevelError) Error() string