Documentation ¶
Index ¶
- Constants
- func AddHook(fn hookFn, opts ...func(*Options)) uint32
- func AddOutput(output io.Writer, opts ...func(*Options))
- func AtLeastLevel(level Level) *minLevelFilter
- func AtLevel(level Level) *exactLevelFilter
- func AtMostLevel(level Level) *maxLevelFilter
- func Contains(text string) *containsFilter
- func Debug(args ...interface{})
- func Debugf(pattern string, args ...interface{})
- func Debugln(args ...interface{})
- func Error(args ...interface{})
- func Errorf(pattern string, args ...interface{})
- func Errorln(args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(pattern string, args ...interface{})
- func Fatalln(args ...interface{})
- func Info(args ...interface{})
- func Infof(pattern string, args ...interface{})
- func Infoln(args ...interface{})
- func JSON() func(*Options)
- func Levels(levels string) func(*Options)
- func MinLevel(l Level) func(*Options)
- func Panic(args ...interface{})
- func Panicf(pattern string, args ...interface{})
- func Panicln(args ...interface{})
- func PlainText() func(o *Options)
- func Print(args ...interface{})
- func Printf(pattern string, args ...interface{})
- func Println(args ...interface{})
- func Regexp(pattern string) *regexpFilter
- func RemoveAllOutputs()
- func RemoveHook(hookID uint32)
- func RemoveOutput(output io.Writer)
- func RenderMessage(args ...interface{}) string
- func SetOutput(output io.Writer, opts ...func(*Options))
- func SetPrefixDelimiter(delimiter string)
- func Trace(args ...interface{})
- func Tracef(pattern string, args ...interface{})
- func Traceln(args ...interface{})
- func Warn(args ...interface{})
- func Warnf(pattern string, args ...interface{})
- func Warning(args ...interface{})
- func Warningf(pattern string, args ...interface{})
- func Warningln(args ...interface{})
- func Warnln(args ...interface{})
- type Entry
- type ExtendedLog
- func (e ExtendedLog) Debug(args ...interface{})
- func (e ExtendedLog) Debugf(pattern string, args ...interface{})
- func (e ExtendedLog) Debugln(args ...interface{})
- func (e ExtendedLog) Error(args ...interface{})
- func (e ExtendedLog) Errorf(pattern string, args ...interface{})
- func (e ExtendedLog) Errorln(args ...interface{})
- func (e ExtendedLog) Extend(f ...F) Log
- func (e ExtendedLog) ExtendPrefix(prefix string, f ...F) Log
- func (e ExtendedLog) Fatal(args ...interface{})
- func (e ExtendedLog) Fatalf(pattern string, args ...interface{})
- func (e ExtendedLog) Fatalln(args ...interface{})
- func (e ExtendedLog) Info(args ...interface{})
- func (e ExtendedLog) Infof(pattern string, args ...interface{})
- func (e ExtendedLog) Infoln(args ...interface{})
- func (e ExtendedLog) Panic(args ...interface{})
- func (e ExtendedLog) Panicf(pattern string, args ...interface{})
- func (e ExtendedLog) Panicln(args ...interface{})
- func (e ExtendedLog) Print(args ...interface{})
- func (e ExtendedLog) Printf(pattern string, args ...interface{})
- func (e ExtendedLog) Println(args ...interface{})
- func (e ExtendedLog) Trace(args ...interface{})
- func (e ExtendedLog) Tracef(pattern string, args ...interface{})
- func (e ExtendedLog) Traceln(args ...interface{})
- func (e ExtendedLog) Warn(args ...interface{})
- func (e ExtendedLog) Warnf(pattern string, args ...interface{})
- func (e ExtendedLog) Warning(args ...interface{})
- func (e ExtendedLog) Warningf(pattern string, args ...interface{})
- func (e ExtendedLog) Warningln(args ...interface{})
- func (e ExtendedLog) Warnln(args ...interface{})
- type F
- type Fields
- type Level
- type Log
- type MockLog
- func (m *MockLog) Count(filters ...filter) (count int)
- func (m *MockLog) Debug(args ...interface{})
- func (m *MockLog) Debugf(pattern string, args ...interface{})
- func (m *MockLog) Debugln(args ...interface{})
- func (m *MockLog) Dump() string
- func (m *MockLog) Error(args ...interface{})
- func (m *MockLog) Errorf(pattern string, args ...interface{})
- func (m *MockLog) Errorln(args ...interface{})
- func (m *MockLog) Extend(f ...F) Log
- func (m *MockLog) ExtendPrefix(prefix string, f ...F) Log
- func (m *MockLog) Fatal(args ...interface{})
- func (m *MockLog) Fatalf(pattern string, args ...interface{})
- func (m *MockLog) Fatalln(args ...interface{})
- func (m *MockLog) Info(args ...interface{})
- func (m *MockLog) Infof(pattern string, args ...interface{})
- func (m *MockLog) Infoln(args ...interface{})
- func (m *MockLog) Message(filters ...filter) (string, bool)
- func (m *MockLog) Messages(filters ...filter) []string
- func (m *MockLog) Panic(args ...interface{})
- func (m *MockLog) Panicf(pattern string, args ...interface{})
- func (m *MockLog) Panicln(args ...interface{})
- func (m *MockLog) Print(args ...interface{})
- func (m *MockLog) Printf(pattern string, args ...interface{})
- func (m *MockLog) Println(args ...interface{})
- func (m *MockLog) Trace(args ...interface{})
- func (m *MockLog) Tracef(pattern string, args ...interface{})
- func (m *MockLog) Traceln(args ...interface{})
- func (m *MockLog) Warn(args ...interface{})
- func (m *MockLog) Warnf(pattern string, args ...interface{})
- func (m *MockLog) Warning(args ...interface{})
- func (m *MockLog) Warningf(pattern string, args ...interface{})
- func (m *MockLog) Warningln(args ...interface{})
- func (m *MockLog) Warnln(args ...interface{})
- type Options
- type OutputFormat
- type PrefixLevel
Constants ¶
const ErrKey = "err"
ErrKey is a reserved for error messages Key
const (
// TimeFormat is the layout to use when rendering time
TimeFormat = "2006-01-02T15:04:05.000"
)
Variables ¶
This section is empty.
Functions ¶
func AddHook ¶
AddHook causes logging activity to invoke the given hook function. It returns an id which can be used to remove the hook with RemoveHook.
func AtLeastLevel ¶
func AtLeastLevel(level Level) *minLevelFilter
func AtMostLevel ¶
func AtMostLevel(level Level) *maxLevelFilter
func Debugf ¶
func Debugf(pattern string, args ...interface{})
Debugf logs a formatted message at debug level
func Errorf ¶
func Errorf(pattern string, args ...interface{})
Errorf logs a formatted message at error level
func Fatalf ¶
func Fatalf(pattern string, args ...interface{})
Fatalf logs a formatted message at fatal level
func Infof ¶
func Infof(pattern string, args ...interface{})
Infof logs a formatted message at info level
func Levels ¶
Levels specifies the minimum log level for an Output. Levels can be specfied by log prefix.
Examples:
// Show debug level and above on stdout lg.SetOutput(os.Stdout, lg.Levels("debug")) // Show info level and above by default, but only show warn and above // for any logs from the "Server" prefix, including sub-prefixes. lg.SetOutput(os.Stdout, lg.Levels("(Server=warn) info")) // Show errors and above, except for logs with the "Request" prefix, // which will show trace and above lg.SetOutput(os.Stdout, lg.Levels("(Request=trace) error"))
The levels string is evaluated left-to-right, so more specific prefixes should be to the left of more general ones.
func Panicf ¶
func Panicf(pattern string, args ...interface{})
Panicf logs a formatted message at fatal level and panics
func Printf ¶
func Printf(pattern string, args ...interface{})
Printf logs a formatted message at info level
func RemoveAllOutputs ¶
func RemoveAllOutputs()
RemoveAllOutputs removes all previously added outputs
func RemoveHook ¶
func RemoveHook(hookID uint32)
RemoveHook removes a previously added hook function
func RemoveOutput ¶
RemoveOutput removes a previously added output
func RenderMessage ¶
func RenderMessage(args ...interface{}) string
func SetPrefixDelimiter ¶
func SetPrefixDelimiter(delimiter string)
func Tracef ¶
func Tracef(pattern string, args ...interface{})
Tracef logs a formatted message at trace level
func Warnf ¶
func Warnf(pattern string, args ...interface{})
Warnf logs a formatted message at warn level
Types ¶
type Entry ¶
type Entry struct { Timestamp time.Time `json:"t"` Prefix string `json:"p,omitempty"` Message string `json:"m"` Level Level `json:"l,string"` Fields Fields `json:"f"` }
Entry represents a log entry
type ExtendedLog ¶
type ExtendedLog struct {
// contains filtered or unexported fields
}
ExtendedLog is a concrete logger interface, optionally with specific fields
func (ExtendedLog) Debug ¶
func (e ExtendedLog) Debug(args ...interface{})
Debug logs a message at debug level
func (ExtendedLog) Debugf ¶
func (e ExtendedLog) Debugf(pattern string, args ...interface{})
Debugf logs a formatted message at debug level
func (ExtendedLog) Debugln ¶
func (e ExtendedLog) Debugln(args ...interface{})
Debugln logs a message at debug level
func (ExtendedLog) Error ¶
func (e ExtendedLog) Error(args ...interface{})
Error logs a message at error level
func (ExtendedLog) Errorf ¶
func (e ExtendedLog) Errorf(pattern string, args ...interface{})
Errorf logs a formatted message at error level
func (ExtendedLog) Errorln ¶
func (e ExtendedLog) Errorln(args ...interface{})
Errorln logs a message at error level
func (ExtendedLog) Extend ¶
func (e ExtendedLog) Extend(f ...F) Log
Extend returns a new sub logger by extending the current one with extra fields.
func (ExtendedLog) ExtendPrefix ¶
func (e ExtendedLog) ExtendPrefix(prefix string, f ...F) Log
ExtendPrefix returns a new sub logger by extending the current one with prefix and extra fields.
func (ExtendedLog) Fatal ¶
func (e ExtendedLog) Fatal(args ...interface{})
Fatal logs a message at fatal level
func (ExtendedLog) Fatalf ¶
func (e ExtendedLog) Fatalf(pattern string, args ...interface{})
Fatalf logs a formatted message at fatal level
func (ExtendedLog) Fatalln ¶
func (e ExtendedLog) Fatalln(args ...interface{})
Fatalln logs a message at fatal level
func (ExtendedLog) Info ¶
func (e ExtendedLog) Info(args ...interface{})
Info logs a message at info level
func (ExtendedLog) Infof ¶
func (e ExtendedLog) Infof(pattern string, args ...interface{})
Infof logs a formatted message at info level
func (ExtendedLog) Infoln ¶
func (e ExtendedLog) Infoln(args ...interface{})
Infoln logs a message at info level
func (ExtendedLog) Panic ¶
func (e ExtendedLog) Panic(args ...interface{})
Panic logs a message at fatal level and panics
func (ExtendedLog) Panicf ¶
func (e ExtendedLog) Panicf(pattern string, args ...interface{})
Panicf logs a formatted message at fatal level and panics
func (ExtendedLog) Panicln ¶
func (e ExtendedLog) Panicln(args ...interface{})
Panicln logs a message at fatal level and panics
func (ExtendedLog) Print ¶
func (e ExtendedLog) Print(args ...interface{})
Print logs a message at info level
func (ExtendedLog) Printf ¶
func (e ExtendedLog) Printf(pattern string, args ...interface{})
Printf logs a formatted message at info level
func (ExtendedLog) Println ¶
func (e ExtendedLog) Println(args ...interface{})
Println logs a message at info level
func (ExtendedLog) Trace ¶
func (e ExtendedLog) Trace(args ...interface{})
Trace logs a message at trace level
func (ExtendedLog) Tracef ¶
func (e ExtendedLog) Tracef(pattern string, args ...interface{})
Tracef logs a formatted message at trace level
func (ExtendedLog) Traceln ¶
func (e ExtendedLog) Traceln(args ...interface{})
Traceln logs a message at trace level
func (ExtendedLog) Warn ¶
func (e ExtendedLog) Warn(args ...interface{})
Warn logs a message at warn level
func (ExtendedLog) Warnf ¶
func (e ExtendedLog) Warnf(pattern string, args ...interface{})
Warnf logs a formatted message at warn level
func (ExtendedLog) Warning ¶
func (e ExtendedLog) Warning(args ...interface{})
Warning logs a message at warn level
func (ExtendedLog) Warningf ¶
func (e ExtendedLog) Warningf(pattern string, args ...interface{})
Warningf logs a formatted message at warn level
func (ExtendedLog) Warningln ¶
func (e ExtendedLog) Warningln(args ...interface{})
Warningln logs a message at warn level
func (ExtendedLog) Warnln ¶
func (e ExtendedLog) Warnln(args ...interface{})
Warnln logs a message at warn level
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
Fields is a slice of field key-value pairs
func ExtractAllFields ¶
func ExtractAllFields( args []interface{}, ) (fields Fields, remaining []interface{})
func ExtractTrailingFields ¶
func ExtractTrailingFields( args []interface{}, ) (fields Fields, remaining []interface{})
type Level ¶
type Level uint
Level is a log level enumerable
Log level literals
func ParseLevel ¶
ParseLevel transforms a string log level into a Level type. Returns an error if the given level is invalid.
func (Level) AlignedString ¶
AlignedString returns the string form of the Level aligned for output
func (Level) MarshalJSON ¶
type Log ¶
type Log interface { Trace(args ...interface{}) Traceln(args ...interface{}) Tracef(pattern string, args ...interface{}) Debug(args ...interface{}) Debugln(args ...interface{}) Debugf(pattern string, args ...interface{}) Print(args ...interface{}) Println(args ...interface{}) Printf(pattern string, args ...interface{}) Info(args ...interface{}) Infoln(args ...interface{}) Infof(pattern string, args ...interface{}) Warn(args ...interface{}) Warnln(args ...interface{}) Warnf(pattern string, args ...interface{}) Warning(args ...interface{}) Warningln(args ...interface{}) Warningf(pattern string, args ...interface{}) Error(args ...interface{}) Errorln(args ...interface{}) Errorf(pattern string, args ...interface{}) Fatal(args ...interface{}) Fatalln(args ...interface{}) Fatalf(pattern string, args ...interface{}) Panic(args ...interface{}) Panicln(args ...interface{}) Panicf(pattern string, args ...interface{}) Extend(f ...F) Log ExtendPrefix(prefix string, f ...F) Log }
Log describes the lg logging interface
func ExtendWithPrefix ¶
type MockLog ¶
type MockLog struct {
// contains filtered or unexported fields
}
func (*MockLog) Debug ¶
func (m *MockLog) Debug(args ...interface{})
Debug logs a message at debug level
func (*MockLog) Debugln ¶
func (m *MockLog) Debugln(args ...interface{})
Debugln logs a message at debug level
func (*MockLog) Dump ¶
Dump produces a string representation of a mock log, suitable for including in assertion/expectation failure messages
func (*MockLog) Error ¶
func (m *MockLog) Error(args ...interface{})
Error logs a message at error level
func (*MockLog) Errorln ¶
func (m *MockLog) Errorln(args ...interface{})
Errorln logs a message at error level
func (*MockLog) Extend ¶
Extend returns a new sub logger by extending the current one with extra fields.
func (*MockLog) ExtendPrefix ¶
ExtendPrefix returns a new sub logger by extending the current one with prefix and extra fields.
func (*MockLog) Fatal ¶
func (m *MockLog) Fatal(args ...interface{})
Fatal logs a message at fatal level
func (*MockLog) Fatalln ¶
func (m *MockLog) Fatalln(args ...interface{})
Fatalln logs a message at fatal level
func (*MockLog) Info ¶
func (m *MockLog) Info(args ...interface{})
Info logs a message at info level
func (*MockLog) Infoln ¶
func (m *MockLog) Infoln(args ...interface{})
Infoln logs a message at info level
func (*MockLog) Panic ¶
func (m *MockLog) Panic(args ...interface{})
Panic logs a message at fatal level and panics
func (*MockLog) Panicln ¶
func (m *MockLog) Panicln(args ...interface{})
Panicln logs a message at fatal level and panics
func (*MockLog) Print ¶
func (m *MockLog) Print(args ...interface{})
Print logs a message at info level
func (*MockLog) Println ¶
func (m *MockLog) Println(args ...interface{})
Println logs a message at info level
func (*MockLog) Trace ¶
func (m *MockLog) Trace(args ...interface{})
Trace logs a message at trace level
func (*MockLog) Traceln ¶
func (m *MockLog) Traceln(args ...interface{})
Traceln logs a message at trace level
func (*MockLog) Warn ¶
func (m *MockLog) Warn(args ...interface{})
Warn logs a message at warn level
func (*MockLog) Warning ¶
func (m *MockLog) Warning(args ...interface{})
Warning logs a message at warn level
type PrefixLevel ¶
type PrefixLevel struct {
// contains filtered or unexported fields
}