Documentation ¶
Index ¶
- type FieldLogger
- type Fields
- type Level
- type Logger
- func (l *Logger) Debug(msg string)
- func (l *Logger) Error(msg string)
- func (l *Logger) Fatal(msg string)
- func (l *Logger) Info(msg string)
- func (l *Logger) SetCallerFrame(caller bool, depth int)
- func (l *Logger) SetColorOutput(color bool)
- func (l *Logger) SetLevel(lvl Level)
- func (l *Logger) SetTimestampFormat(f string)
- func (l *Logger) SetWriter(w io.Writer)
- func (l *Logger) Warn(msg string)
- func (l *Logger) WithError(err error) *FieldLogger
- func (l *Logger) WithFields(fields Fields) *FieldLogger
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldLogger ¶ added in v0.3.1
type FieldLogger struct {
// contains filtered or unexported fields
}
func (*FieldLogger) Debug ¶ added in v0.3.1
func (l *FieldLogger) Debug(msg string)
func (*FieldLogger) Error ¶ added in v0.3.1
func (l *FieldLogger) Error(msg string)
Error emits an error log line.
func (*FieldLogger) Fatal ¶ added in v0.3.2
func (l *FieldLogger) Fatal(msg string)
Fatal emits a fatal level log line. It aborts the current program with an exit code of 1.
func (*FieldLogger) Info ¶ added in v0.3.1
func (l *FieldLogger) Info(msg string)
Info emits a info log line.
func (*FieldLogger) Warn ¶ added in v0.3.1
func (l *FieldLogger) Warn(msg string)
Warn emits a warning log line.
type Fields ¶
Fields is a map of arbitrary KV pairs which will be used in logfmt representation of the log.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the interface for all log operations related to emitting logs.
func New ¶
func New() *Logger
New instantiates a logger object. It writes to `stderr` as the default and it's non configurable.
func (*Logger) Fatal ¶
Fatal emits a fatal level log line. It aborts the current program with an exit code of 1.
func (*Logger) SetCallerFrame ¶
SetCallerFrame enables/disables the caller source in the log line.
func (*Logger) SetColorOutput ¶
SetColorOutput enables/disables colored output.
func (*Logger) SetLevel ¶
SetLevel sets the verbosity for logger. Verbosity can be dynamically changed by the caller.
func (*Logger) SetTimestampFormat ¶
SetTimestampFormat sets the timestamp format for the `timestamp` key.
func (*Logger) WithError ¶
func (l *Logger) WithError(err error) *FieldLogger
WithError returns a Logger with the "error" key set to `err`.
func (*Logger) WithFields ¶
func (l *Logger) WithFields(fields Fields) *FieldLogger
WithFields returns a new entry with `fields` set.
type Opts ¶
type Opts struct { Writer io.Writer Lvl Level TimestampFormat string EnableColor bool EnableCaller bool // CallerSkipFrameCount is the count of the number of frames to skip when computing the file name and line number CallerSkipFrameCount int }
Opts represents various properties to configure logger.