Documentation
¶
Index ¶
- func AddSafety(w io.Writer) io.Writer
- func Debug(a ...interface{})
- func Debugf(s string, a ...interface{})
- func Error(a ...interface{})
- func Errorf(s string, a ...interface{})
- func Fatal(a ...interface{})
- func Fatalf(s string, a ...interface{})
- func Info(a ...interface{})
- func Infof(s string, a ...interface{})
- func Log(lvl LEVEL, a ...interface{})
- func Logf(lvl LEVEL, s string, a ...interface{})
- func Print(a ...interface{})
- func Printf(s string, a ...interface{})
- func Warn(a ...interface{})
- func Warnf(s string, a ...interface{})
- type Entry
- func (e *Entry) Bool(key string, value bool) *Entry
- func (e *Entry) Bools(key string, value []bool) *Entry
- func (e *Entry) Byte(key string, value byte) *Entry
- func (e *Entry) Bytes(key string, value []byte) *Entry
- func (e *Entry) Context() context.Context
- func (e *Entry) Duration(key string, value time.Duration) *Entry
- func (e *Entry) Durations(key string, value []time.Duration) *Entry
- func (e *Entry) Field(key string, value interface{}) *Entry
- func (e *Entry) Fields(fields map[string]interface{}) *Entry
- func (e *Entry) Float(key string, value float64) *Entry
- func (e *Entry) Floats(key string, value []float64) *Entry
- func (e *Entry) Hooks() *Entry
- func (e *Entry) Int(key string, value int) *Entry
- func (e *Entry) Ints(key string, value []int) *Entry
- func (e *Entry) Level(lvl LEVEL) *Entry
- func (e *Entry) Msg(a ...interface{})
- func (e *Entry) Msgf(s string, a ...interface{})
- func (e *Entry) Send()
- func (e *Entry) Str(key string, value string) *Entry
- func (e *Entry) Strs(key string, value []string) *Entry
- func (e *Entry) Time(key string, value time.Time) *Entry
- func (e *Entry) Times(key string, value []time.Time) *Entry
- func (e *Entry) Timestamp() *Entry
- func (e *Entry) TimestampIf() *Entry
- func (e *Entry) Uint(key string, value uint) *Entry
- func (e *Entry) Uints(key string, value []uint) *Entry
- func (e *Entry) WithContext(ctx context.Context) *Entry
- type Hook
- type HookFunc
- type LEVEL
- type Levels
- type LogFormat
- type Logger
- func (l *Logger) Debug(a ...interface{})
- func (l *Logger) Debugf(s string, a ...interface{})
- func (l *Logger) Entry() *Entry
- func (l *Logger) Error(a ...interface{})
- func (l *Logger) Errorf(s string, a ...interface{})
- func (l *Logger) Fatal(a ...interface{})
- func (l *Logger) Fatalf(s string, a ...interface{})
- func (l *Logger) Info(a ...interface{})
- func (l *Logger) Infof(s string, a ...interface{})
- func (l *Logger) Log(lvl LEVEL, a ...interface{})
- func (l *Logger) Logf(lvl LEVEL, s string, a ...interface{})
- func (l *Logger) Print(a ...interface{})
- func (l *Logger) Printf(s string, a ...interface{})
- func (l *Logger) Warn(a ...interface{})
- func (l *Logger) Warnf(s string, a ...interface{})
- type TextFormat
- func (f *TextFormat) AppendBoolField(buf *bytes.Buffer, key string, value bool)
- func (f *TextFormat) AppendBoolsField(buf *bytes.Buffer, key string, value []bool)
- func (f *TextFormat) AppendByteField(buf *bytes.Buffer, key string, value byte)
- func (f *TextFormat) AppendBytesField(buf *bytes.Buffer, key string, value []byte)
- func (f *TextFormat) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration)
- func (f *TextFormat) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration)
- func (f *TextFormat) AppendField(buf *bytes.Buffer, key string, value interface{})
- func (f *TextFormat) AppendFields(buf *bytes.Buffer, fields map[string]interface{})
- func (f *TextFormat) AppendFloatField(buf *bytes.Buffer, key string, value float64)
- func (f *TextFormat) AppendFloatsField(buf *bytes.Buffer, key string, value []float64)
- func (f *TextFormat) AppendIntField(buf *bytes.Buffer, key string, value int)
- func (f *TextFormat) AppendIntsField(buf *bytes.Buffer, key string, value []int)
- func (f *TextFormat) AppendLevel(buf *bytes.Buffer, lvl LEVEL)
- func (f *TextFormat) AppendMsg(buf *bytes.Buffer, a ...interface{})
- func (f *TextFormat) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{})
- func (f *TextFormat) AppendStringField(buf *bytes.Buffer, key string, value string)
- func (f *TextFormat) AppendStringsField(buf *bytes.Buffer, key string, value []string)
- func (f *TextFormat) AppendTimeField(buf *bytes.Buffer, key string, value time.Time)
- func (f *TextFormat) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time)
- func (f *TextFormat) AppendTimestamp(buf *bytes.Buffer, now string)
- func (f *TextFormat) AppendUintField(buf *bytes.Buffer, key string, value uint)
- func (f *TextFormat) AppendUintsField(buf *bytes.Buffer, key string, value []uint)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(a ...interface{})
Debug prints the provided arguments with the debug prefix to the global Logger instance
func Debugf ¶
func Debugf(s string, a ...interface{})
Debugf prints the provided format string and arguments with the debug prefix to the global Logger instance
func Error ¶
func Error(a ...interface{})
Error prints the provided arguments with the error prefix to the global Logger instance
func Errorf ¶
func Errorf(s string, a ...interface{})
Errorf prints the provided format string and arguments with the error prefix to the global Logger instance
func Fatal ¶
func Fatal(a ...interface{})
Fatal prints the provided arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1)
func Fatalf ¶
func Fatalf(s string, a ...interface{})
Fatalf prints the provided format string and arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1)
func Info ¶
func Info(a ...interface{})
Info prints the provided arguments with the info prefix to the global Logger instance
func Infof ¶
func Infof(s string, a ...interface{})
Infof prints the provided format string and arguments with the info prefix to the global Logger instance
func Log ¶
func Log(lvl LEVEL, a ...interface{})
Log prints the provided arguments with the supplied log level to the global Logger instance
func Logf ¶
Logf prints the provided format string and arguments with the supplied log level to the global Logger instance
func Print ¶
func Print(a ...interface{})
Print simply prints provided arguments to the global Logger instance
func Printf ¶
func Printf(s string, a ...interface{})
Printf simply prints provided the provided format string and arguments to the global Logger instance
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry defines an entry in the log, it is NOT safe for concurrent use
func (*Entry) Durations ¶
Durations appends a time.Duration slice value as key-value pair to the log entry
func (*Entry) Hooks ¶
Hooks applies currently set Hooks to the Entry. Please note this CAN be called and perform the Hooks multiple times
func (*Entry) Level ¶
Level appends the supplied level to the log entry, and sets the entry level. Please note this CAN be called and append log levels multiple times
func (*Entry) Msg ¶
func (e *Entry) Msg(a ...interface{})
Msg appends the formatted final message to the log and calls .Send()
func (*Entry) Send ¶
func (e *Entry) Send()
Send triggers write of the log entry, skipping if the entry's log LEVEL is below the currently set Logger level, and releases the Entry back to the Logger's Entry pool. So it is NOT safe to continue using this Entry object after calling .Send(), .Msg() or .Msgf()
func (*Entry) Timestamp ¶
Timestamp appends the current timestamp to the log entry. Please note this CAN be called and append the timestamp multiple times
func (*Entry) TimestampIf ¶
TimestampIf performs Entry.Timestamp() only IF timestamping is enabled for the Logger. Please note this CAN be called multiple times
type HookFunc ¶
type HookFunc func(*Entry)
HookFunc is a simple adapter to allow functions to satisfy the Hook interface
type Levels ¶
Levels defines a mapping of log LEVELs to formatted level strings
func DefaultLevels ¶
func DefaultLevels() Levels
DefaultLevels returns the default set of log levels
func (Levels) LevelString ¶
LevelString fetches the appropriate level string for the provided level, or "unknown"
type LogFormat ¶
type LogFormat interface { AppendLevel(buf *bytes.Buffer, lvl LEVEL) AppendTimestamp(buf *bytes.Buffer, fmtNow string) AppendField(buf *bytes.Buffer, key string, value interface{}) AppendFields(buf *bytes.Buffer, fields map[string]interface{}) AppendByteField(buf *bytes.Buffer, key string, value byte) AppendBytesField(buf *bytes.Buffer, key string, value []byte) AppendStringField(buf *bytes.Buffer, key string, value string) AppendStringsField(buf *bytes.Buffer, key string, value []string) AppendBoolField(buf *bytes.Buffer, key string, value bool) AppendBoolsField(buf *bytes.Buffer, key string, value []bool) AppendIntField(buf *bytes.Buffer, key string, value int) AppendIntsField(buf *bytes.Buffer, key string, value []int) AppendUintField(buf *bytes.Buffer, key string, value uint) AppendUintsField(buf *bytes.Buffer, key string, value []uint) AppendFloatField(buf *bytes.Buffer, key string, value float64) AppendFloatsField(buf *bytes.Buffer, key string, value []float64) AppendTimeField(buf *bytes.Buffer, key string, value time.Time) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration) AppendMsg(buf *bytes.Buffer, a ...interface{}) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{}) }
LogFormat defines a method of formatting log entries
type Logger ¶
type Logger struct { // Hooks defines a list of hooks which are called before an entry // is written. This should NOT be modified while the Logger is in use Hooks []Hook // Level is the current log LEVEL, entries at level below the // currently set level will not be output. This should NOT // be modified while the Logger is in use Level LEVEL // Timestamp defines whether to automatically append timestamps // to entries written via Logger convience methods and specifically // Entry.TimestampIf(). This should NOT be modified while Logger in use Timestamp bool // Format is the log entry LogFormat to use. This should NOT // be modified while the Logger is in use Format LogFormat // BufferSize is the Entry buffer size to use when allocating // new Entry objects. This should be modified atomically BufSize int64 // Output is the log's output writer. This should NOT be // modified while the Logger is in use Output io.Writer // contains filtered or unexported fields }
func (*Logger) Debug ¶
func (l *Logger) Debug(a ...interface{})
Debug prints the provided arguments with the debug prefix
func (*Logger) Debugf ¶
Debugf prints the provided format string and arguments with the debug prefix
func (*Logger) Error ¶
func (l *Logger) Error(a ...interface{})
Error prints the provided arguments with the error prefix
func (*Logger) Errorf ¶
Errorf prints the provided format string and arguments with the error prefix
func (*Logger) Fatal ¶
func (l *Logger) Fatal(a ...interface{})
Fatal prints provided arguments with the fatal prefix before exiting the program with os.Exit(1)
func (*Logger) Fatalf ¶
Fatalf prints provided the provided format string and arguments with the fatal prefix before exiting the program with os.Exit(1)
func (*Logger) Info ¶
func (l *Logger) Info(a ...interface{})
Info prints the provided arguments with the info prefix
func (*Logger) Logf ¶
Logf prints the provided format string and arguments with the supplied log level
func (*Logger) Print ¶
func (l *Logger) Print(a ...interface{})
Print simply prints provided arguments
type TextFormat ¶
type TextFormat struct { // Strict defines whether to use strict key-value pair formatting, i.e. should the level // timestamp and msg be formatted as key-value pairs (with forced quoting for msg) Strict bool // Levels defines the map of log LEVELs to level strings this LogFormat will use Levels Levels }
TextFormat is the default LogFormat implementation, with very similar formatting to logfmt
func NewTextFormat ¶ added in v1.1.0
func NewTextFormat(strict bool) *TextFormat
NewLogFmt returns a newly set LogFmt object, with DefaultLevels() set
func (*TextFormat) AppendBoolField ¶
func (f *TextFormat) AppendBoolField(buf *bytes.Buffer, key string, value bool)
func (*TextFormat) AppendBoolsField ¶
func (f *TextFormat) AppendBoolsField(buf *bytes.Buffer, key string, value []bool)
func (*TextFormat) AppendByteField ¶
func (f *TextFormat) AppendByteField(buf *bytes.Buffer, key string, value byte)
func (*TextFormat) AppendBytesField ¶
func (f *TextFormat) AppendBytesField(buf *bytes.Buffer, key string, value []byte)
func (*TextFormat) AppendDurationField ¶
func (f *TextFormat) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration)
func (*TextFormat) AppendDurationsField ¶
func (f *TextFormat) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration)
func (*TextFormat) AppendField ¶
func (f *TextFormat) AppendField(buf *bytes.Buffer, key string, value interface{})
func (*TextFormat) AppendFields ¶
func (f *TextFormat) AppendFields(buf *bytes.Buffer, fields map[string]interface{})
func (*TextFormat) AppendFloatField ¶
func (f *TextFormat) AppendFloatField(buf *bytes.Buffer, key string, value float64)
func (*TextFormat) AppendFloatsField ¶
func (f *TextFormat) AppendFloatsField(buf *bytes.Buffer, key string, value []float64)
func (*TextFormat) AppendIntField ¶
func (f *TextFormat) AppendIntField(buf *bytes.Buffer, key string, value int)
func (*TextFormat) AppendIntsField ¶
func (f *TextFormat) AppendIntsField(buf *bytes.Buffer, key string, value []int)
func (*TextFormat) AppendLevel ¶
func (f *TextFormat) AppendLevel(buf *bytes.Buffer, lvl LEVEL)
func (*TextFormat) AppendMsg ¶
func (f *TextFormat) AppendMsg(buf *bytes.Buffer, a ...interface{})
func (*TextFormat) AppendMsgf ¶
func (f *TextFormat) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{})
func (*TextFormat) AppendStringField ¶
func (f *TextFormat) AppendStringField(buf *bytes.Buffer, key string, value string)
func (*TextFormat) AppendStringsField ¶
func (f *TextFormat) AppendStringsField(buf *bytes.Buffer, key string, value []string)
func (*TextFormat) AppendTimeField ¶
func (f *TextFormat) AppendTimeField(buf *bytes.Buffer, key string, value time.Time)
func (*TextFormat) AppendTimesField ¶
func (f *TextFormat) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time)
func (*TextFormat) AppendTimestamp ¶
func (f *TextFormat) AppendTimestamp(buf *bytes.Buffer, now string)
func (*TextFormat) AppendUintField ¶
func (f *TextFormat) AppendUintField(buf *bytes.Buffer, key string, value uint)
func (*TextFormat) AppendUintsField ¶
func (f *TextFormat) AppendUintsField(buf *bytes.Buffer, key string, value []uint)