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 ¶
type FileLogger struct { Logger *log.Logger LogLevel LogLevel // contains filtered or unexported fields }
FileLogger ...
func (*FileLogger) Warningf ¶
func (l *FileLogger) Warningf(f string, v ...interface{})
Warningf ...
type JsonLogger ¶
type JsonLogger struct {
// contains filtered or unexported fields
}
JsonLogger is a logger implementation for json logging.
func NewJSONLogger ¶
func NewJSONLogger(opts *Options) (*JsonLogger, error)
NewJSONLogger returns a json logger.
func (*JsonLogger) Debug ¶
func (l *JsonLogger) Debug(msg string, args ...interface{})
Debugf prints the message and args at DEBUG level
func (*JsonLogger) Debugf ¶
func (l *JsonLogger) Debugf(msg string, args ...interface{})
Debugf prints the message and args at DEBUG level
func (*JsonLogger) Error ¶
func (l *JsonLogger) Error(msg string, args ...interface{})
Errorf prints the message and args at ERROR level
func (*JsonLogger) Errorf ¶
func (l *JsonLogger) Errorf(msg string, args ...interface{})
Errorf prints the message and args at ERROR level
func (*JsonLogger) Info ¶
func (l *JsonLogger) Info(msg string, args ...interface{})
Infof prints the message and args at INFO level
func (*JsonLogger) Infof ¶
func (l *JsonLogger) Infof(msg string, args ...interface{})
Infof prints the message and args at INFO level
func (*JsonLogger) SetLogLevel ¶
func (l *JsonLogger) SetLogLevel(level LogLevel)
Update the logging level
func (*JsonLogger) Warning ¶
func (l *JsonLogger) Warning(msg string, args ...interface{})
Warningf prints the message and args at WARN level
func (*JsonLogger) Warningf ¶
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 ¶
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 ¶
type MemoryLogger struct {
// contains filtered or unexported fields
}
func NewMemoryLogger ¶
func NewMemoryLogger() *MemoryLogger
func NewMemoryLoggerWithLevel ¶
func NewMemoryLoggerWithLevel(level LogLevel) *MemoryLogger
func (*MemoryLogger) Debugf ¶
func (l *MemoryLogger) Debugf(fmt string, args ...interface{})
func (*MemoryLogger) Errorf ¶
func (l *MemoryLogger) Errorf(fmt string, args ...interface{})
func (*MemoryLogger) GetLogs ¶
func (l *MemoryLogger) GetLogs() []string
func (*MemoryLogger) Infof ¶
func (l *MemoryLogger) Infof(fmt string, args ...interface{})
func (*MemoryLogger) Warningf ¶
func (l *MemoryLogger) Warningf(fmt string, args ...interface{})
type Options ¶
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 ¶
SimpleLogger ...
func (*SimpleLogger) Warningf ¶
func (l *SimpleLogger) Warningf(f string, v ...interface{})
Warningf ...