Documentation ¶
Overview ¶
Package log2 solves these issues: - log level filtering, e.g. show debug messages in internal tests only - safe concurrent change of log level
Primary goal was to run parallel tests and log into t.Logf() safely, and TBH, would have been enough to pass around explicit stdlib *log.Logger. Well, log levels is just a cherry on top.
Index ¶
- Constants
- type ErrorFunc
- type FmtFunc
- type FmtFuncWriter
- type Level
- type Log
- func (lg *Log) Clone(level Level) *Log
- func (lg *Log) Debug(args ...interface{})
- func (lg *Log) Debugf(format string, args ...interface{})
- func (lg *Log) Enabled(level Level) bool
- func (lg *Log) Error(args ...interface{})
- func (lg *Log) Errorf(format string, args ...interface{})
- func (lg *Log) Fatal(args ...interface{})
- func (lg *Log) Fatalf(format string, args ...interface{})
- func (lg *Log) Info(args ...interface{})
- func (lg *Log) Infof(format string, args ...interface{})
- func (lg *Log) Log(level Level, s string)
- func (lg *Log) Logf(level Level, format string, args ...interface{})
- func (lg *Log) Printf(format string, args ...interface{})
- func (lg *Log) Println(args ...interface{})
- func (lg *Log) SetErrorFunc(f ErrorFunc)
- func (lg *Log) SetFlags(f int)
- func (lg *Log) SetLevel(l Level)
- func (lg *Log) SetOutput(w io.Writer)
- func (lg *Log) SetPrefix(prefix string)
- func (lg *Log) Stdlib() *log.Logger
Constants ¶
View Source
const ( // type specified here helped against accidentally passing flags as level Lmicroseconds int = log.Lmicroseconds Lshortfile int = log.Lshortfile LStdFlags int = log.Ltime | Lshortfile LInteractiveFlags int = log.Ltime | Lshortfile | Lmicroseconds LServiceFlags int = Lshortfile LTestFlags int = Lshortfile | Lmicroseconds )
View Source
const ( LError = iota LInfo LDebug LAll = math.MaxInt32 )
View Source
const ContextKey = "run/log"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FmtFuncWriter ¶
type FmtFuncWriter struct{ FmtFunc }
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func ContextValueLogger ¶
func (*Log) SetErrorFunc ¶
Click to show internal directories.
Click to hide internal directories.