Documentation ¶
Index ¶
- func CapLogCache(size int)
- func FormatLog(log *Log) string
- func TurboLevelFilter(threshold Level) func(Level, string, ...interface{}) bool
- type Appender
- type FileAppender
- type Filter
- type FilterAppender
- type Level
- type Log
- type LogCache
- type Logger
- type StackError
- type StringAppender
- type TurboFilter
- type WriteStringer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapLogCache ¶
func CapLogCache(size int)
Types ¶
type FileAppender ¶
type FileAppender struct {
WriteStringer
}
WriteStringer is implemented by *os.File.
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
type FilterAppender ¶
func LevelFilter ¶
func LevelFilter(threshold Level, appender Appender) *FilterAppender
func (*FilterAppender) Append ¶
func (self *FilterAppender) Append(log *Log) 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 LogCache ¶
type LogCache struct { // A `LogCache` might be accessed concurrently throughout the // program. Therefore, the code calling `Log` acquires a mutex for // writing to (and potentially reading from) the // ring. Alternatively, if channels are more efficient, the `Log` // method can instead pass the *Log through a channel. A goroutine // on the other end can be the sole maintainer of the `LogCache`, // removing the need for a mutex. sync.Mutex // contains filtered or unexported fields }
var Cache LogCache
type Logger ¶
type Logger struct { Prefix string Appenders []Appender TurboFilters []TurboFilter }
func (*Logger) Errorf ¶
Log and return a formatted error string. Example:
if whatIsExpected != whatIsReturned { return slogger.Errorf(slogger.WARN, "Unexpected return value. Expected: %v Received: %v", whatIsExpected, whatIsReturned) }
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) 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.
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
type TurboFilter ¶
enables level-filtering before a Log entry is created, avoiding the runtime.Caller invocation return true if filter evaluation should continue