Documentation
¶
Index ¶
- Constants
- type Configuration
- type Fields
- type Logger
- type LogrusLogEntry
- func (l *LogrusLogEntry) Debugf(format string, args ...interface{})
- func (l *LogrusLogEntry) Errorf(format string, args ...interface{})
- func (l *LogrusLogEntry) Fatalf(format string, args ...interface{})
- func (l *LogrusLogEntry) Infof(format string, args ...interface{})
- func (l *LogrusLogEntry) Panicf(format string, args ...interface{})
- func (l *LogrusLogEntry) Warnf(format string, args ...interface{})
- func (l *LogrusLogEntry) WithFields(fields Fields) Logger
- type LogrusLogger
- func (l *LogrusLogger) Debugf(format string, args ...interface{})
- func (l *LogrusLogger) Errorf(format string, args ...interface{})
- func (l *LogrusLogger) Fatalf(format string, args ...interface{})
- func (l *LogrusLogger) Infof(format string, args ...interface{})
- func (l *LogrusLogger) Panicf(format string, args ...interface{})
- func (l *LogrusLogger) Warnf(format string, args ...interface{})
- func (l *LogrusLogger) WithFields(fields Fields) Logger
Constants ¶
View Source
const ( //Debug has verbose message Debug = "debug" //Info is default log level Info = "info" //Warn is for logging messages about possible issues Warn = "warn" //Error is for logging errors Error = "error" //Fatal is for logging fatal messages. The sytem shutsdown after logging the message. Fatal = "fatal" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct {
EnableConsole bool
ConsoleJSONFormat bool
ConsoleLevel string
EnableFile bool
FileJSONFormat bool
FileLevel string
// Filename is the file to write logs to. Backup log files will be retained
// in the same directory. It uses <processname>-lumberjack.log in
// os.TempDir() if empty.
Filename string
// MaxSize is the maximum size in megabytes of the log file before it gets
// rotated. It defaults to 100 megabytes.
MaxSizeMB int
// MaxAge is the maximum number of days to retain old log files based on the
// timestamp encoded in their filename. Note that a day is defined as 24
// hours and may not exactly correspond to calendar days due to daylight
// savings, leap seconds, etc. The default is 7 days.
MaxAgeDays int
// MaxBackups is the maximum number of old log files to retain. The default
// is to retain all old log files (though MaxAge may still cause them to get
// deleted.)
MaxBackups int
// LocalTime determines if the time used for formatting the timestamps in
// backup files is the computer's local time. The default is to use UTC
// time.
LocalTime bool
}
Configuration stores the config for the logger For some loggers there can only be one level across writers, for such the level of Console is picked by default
type Fields ¶
type Fields map[string]interface{}
Fields Type to pass when we want to call WithFields for structured logging
type Logger ¶
type Logger interface {
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{})
WithFields(keyValues Fields) Logger
}
Logger is the common interface for logging.
func NewLogrusLogger ¶
func NewLogrusLogger(lLogger logrus.FieldLogger) Logger
NewLogrusLogger adapts existing logrus logger to Logger interface. The call is responsible for configuring logrus logger appropriately.
func NewLogrusLoggerWithConfig ¶
func NewLogrusLoggerWithConfig(config Configuration) Logger
NewLogrusLoggerWithConfig creates and configs Logger instance backed by logrus logger.
type LogrusLogEntry ¶
type LogrusLogEntry struct {
// contains filtered or unexported fields
}
func (*LogrusLogEntry) Debugf ¶
func (l *LogrusLogEntry) Debugf(format string, args ...interface{})
func (*LogrusLogEntry) Errorf ¶
func (l *LogrusLogEntry) Errorf(format string, args ...interface{})
func (*LogrusLogEntry) Fatalf ¶
func (l *LogrusLogEntry) Fatalf(format string, args ...interface{})
func (*LogrusLogEntry) Infof ¶
func (l *LogrusLogEntry) Infof(format string, args ...interface{})
func (*LogrusLogEntry) Panicf ¶
func (l *LogrusLogEntry) Panicf(format string, args ...interface{})
func (*LogrusLogEntry) Warnf ¶
func (l *LogrusLogEntry) Warnf(format string, args ...interface{})
func (*LogrusLogEntry) WithFields ¶
func (l *LogrusLogEntry) WithFields(fields Fields) Logger
type LogrusLogger ¶
type LogrusLogger struct {
// contains filtered or unexported fields
}
func (*LogrusLogger) Debugf ¶
func (l *LogrusLogger) Debugf(format string, args ...interface{})
func (*LogrusLogger) Errorf ¶
func (l *LogrusLogger) Errorf(format string, args ...interface{})
func (*LogrusLogger) Fatalf ¶
func (l *LogrusLogger) Fatalf(format string, args ...interface{})
func (*LogrusLogger) Infof ¶
func (l *LogrusLogger) Infof(format string, args ...interface{})
func (*LogrusLogger) Panicf ¶
func (l *LogrusLogger) Panicf(format string, args ...interface{})
func (*LogrusLogger) Warnf ¶
func (l *LogrusLogger) Warnf(format string, args ...interface{})
func (*LogrusLogger) WithFields ¶
func (l *LogrusLogger) WithFields(fields Fields) Logger
Click to show internal directories.
Click to hide internal directories.