Documentation ¶
Index ¶
- Constants
- Variables
- type FileLogger
- type JsonLogger
- func (i *JsonLogger) Close() error
- func (l *JsonLogger) Debug(msg string, args ...interface{})
- func (l *JsonLogger) Debugf(msg string, args ...interface{})
- func (l *JsonLogger) Error(msg string, args ...interface{})
- func (l *JsonLogger) Errorf(msg string, args ...interface{})
- func (l *JsonLogger) Info(msg string, args ...interface{})
- func (l *JsonLogger) Infof(msg string, args ...interface{})
- func (i *JsonLogger) Name() string
- func (l *JsonLogger) SetLogLevel(level LogLevel)
- func (l *JsonLogger) Warning(msg string, args ...interface{})
- func (l *JsonLogger) Warningf(msg string, args ...interface{})
- type LogLevel
- type Logger
- func NewFileLogger(name string, file string) (logger Logger, out *os.File, err error)
- func NewFileLoggerWithLevel(name string, file string, level LogLevel) (logger Logger, err error)
- func NewLogger(opts *Options) (logger Logger, err error)
- func NewSimpleLogger(name string, out io.Writer) Logger
- func NewSimpleLoggerWithLevel(name string, out io.Writer, level LogLevel) Logger
- type MemoryLogger
- func (l *MemoryLogger) Close() error
- func (l *MemoryLogger) Debugf(fmt string, args ...interface{})
- func (l *MemoryLogger) Errorf(fmt string, args ...interface{})
- func (l *MemoryLogger) GetLogs() []string
- func (l *MemoryLogger) Infof(fmt string, args ...interface{})
- func (l *MemoryLogger) Warningf(fmt string, args ...interface{})
- type Options
- type SimpleLogger
- type TimeFunc
Constants ¶
const ( // DefaultTimeFormat is the time format to use for JSON output DefaultTimeFormat = "2006-01-02T15:04:05.000000Z07:00" // LogFormatText is the log format to use for TEXT output LogFormatText = "text" // LogFormatJSON is the log format to use for JSON output LogFormatJSON = "json" )
Variables ¶
var (
ErrInvalidLoggerType = errors.New("invalid logger type")
)
Functions ¶
This section is empty.
Types ¶
type FileLogger ¶ added in v0.7.0
type FileLogger struct { Logger *log.Logger LogLevel LogLevel // contains filtered or unexported fields }
FileLogger ...
func (*FileLogger) Debugf ¶ added in v0.7.0
func (l *FileLogger) Debugf(f string, v ...interface{})
Debugf ...
func (*FileLogger) Errorf ¶ added in v0.7.0
func (l *FileLogger) Errorf(f string, v ...interface{})
Errorf ...
func (*FileLogger) Infof ¶ added in v0.7.0
func (l *FileLogger) Infof(f string, v ...interface{})
Infof ...
func (*FileLogger) Warningf ¶ added in v0.7.0
func (l *FileLogger) Warningf(f string, v ...interface{})
Warningf ...
type JsonLogger ¶ added in v1.3.2
type JsonLogger struct {
// contains filtered or unexported fields
}
JsonLogger is a logger implementation for json logging.
func NewJSONLogger ¶ added in v1.3.2
func NewJSONLogger(opts *Options) (*JsonLogger, error)
NewJSONLogger returns a json logger.
func (*JsonLogger) Debug ¶ added in v1.3.2
func (l *JsonLogger) Debug(msg string, args ...interface{})
Debugf prints the message and args at DEBUG level
func (*JsonLogger) Debugf ¶ added in v1.3.2
func (l *JsonLogger) Debugf(msg string, args ...interface{})
Debugf prints the message and args at DEBUG level
func (*JsonLogger) Error ¶ added in v1.3.2
func (l *JsonLogger) Error(msg string, args ...interface{})
Errorf prints the message and args at ERROR level
func (*JsonLogger) Errorf ¶ added in v1.3.2
func (l *JsonLogger) Errorf(msg string, args ...interface{})
Errorf prints the message and args at ERROR level
func (*JsonLogger) Info ¶ added in v1.3.2
func (l *JsonLogger) Info(msg string, args ...interface{})
Infof prints the message and args at INFO level
func (*JsonLogger) Infof ¶ added in v1.3.2
func (l *JsonLogger) Infof(msg string, args ...interface{})
Infof prints the message and args at INFO level
func (*JsonLogger) Name ¶ added in v1.3.2
func (i *JsonLogger) Name() string
Name returns the loggers name
func (*JsonLogger) SetLogLevel ¶ added in v1.3.2
func (l *JsonLogger) SetLogLevel(level LogLevel)
Update the logging level
func (*JsonLogger) Warning ¶ added in v1.3.2
func (l *JsonLogger) Warning(msg string, args ...interface{})
Warningf prints the message and args at WARN level
func (*JsonLogger) Warningf ¶ added in v1.3.2
func (l *JsonLogger) Warningf(msg string, args ...interface{})
Warningf prints the message and args at WARN level
type LogLevel ¶
type LogLevel int8
LogLevel ...
func LogLevelFromEnvironment ¶ added in v1.3.2
func LogLevelFromEnvironment() LogLevel
type Logger ¶
type Logger interface { Errorf(string, ...interface{}) Warningf(string, ...interface{}) Infof(string, ...interface{}) Debugf(string, ...interface{}) Close() error }
Logger ...
func NewFileLogger ¶
NewFileLogger ...
func NewFileLoggerWithLevel ¶
NewFileLoggerWithLevel ...
type MemoryLogger ¶ added in v1.3.2
type MemoryLogger struct {
// contains filtered or unexported fields
}
func NewMemoryLogger ¶ added in v1.3.2
func NewMemoryLogger() *MemoryLogger
func NewMemoryLoggerWithLevel ¶ added in v1.3.2
func NewMemoryLoggerWithLevel(level LogLevel) *MemoryLogger
func (*MemoryLogger) Close ¶ added in v1.3.2
func (l *MemoryLogger) Close() error
Close the logger ...
func (*MemoryLogger) Debugf ¶ added in v1.3.2
func (l *MemoryLogger) Debugf(fmt string, args ...interface{})
func (*MemoryLogger) Errorf ¶ added in v1.3.2
func (l *MemoryLogger) Errorf(fmt string, args ...interface{})
func (*MemoryLogger) GetLogs ¶ added in v1.3.2
func (l *MemoryLogger) GetLogs() []string
func (*MemoryLogger) Infof ¶ added in v1.3.2
func (l *MemoryLogger) Infof(fmt string, args ...interface{})
func (*MemoryLogger) Warningf ¶ added in v1.3.2
func (l *MemoryLogger) Warningf(fmt string, args ...interface{})
type Options ¶ added in v1.3.2
type Options struct { // Name of the subsystem to prefix logs with Name string // The threshold for the logger. Anything less severe is supressed Level LogLevel // Where to write the logs to. Defaults to os.Stderr if nil Output io.Writer // The time format to use instead of the default TimeFormat string // A function which is called to get the time object that is formatted using `TimeFormat` TimeFnc TimeFunc // The format in which logs will be formatted. (eg: text/json) LogFormat string // The file to write to. LogFile string }
Options can be used to configure a new logger.
type SimpleLogger ¶ added in v0.7.0
SimpleLogger ...
func (*SimpleLogger) Close ¶ added in v1.3.2
func (l *SimpleLogger) Close() error
Close the logger ...
func (*SimpleLogger) Debugf ¶ added in v0.7.0
func (l *SimpleLogger) Debugf(f string, v ...interface{})
Debugf ...
func (*SimpleLogger) Errorf ¶ added in v0.7.0
func (l *SimpleLogger) Errorf(f string, v ...interface{})
Errorf ...
func (*SimpleLogger) Infof ¶ added in v0.7.0
func (l *SimpleLogger) Infof(f string, v ...interface{})
Infof ...
func (*SimpleLogger) Warningf ¶ added in v0.7.0
func (l *SimpleLogger) Warningf(f string, v ...interface{})
Warningf ...