Documentation ¶
Index ¶
- func GetCaller() *runtime.Frame
- type CustomGraylogHook
- type LogMsg
- type Logger
- type LoggerBuilderFn
- type Logrus
- func (lr *Logrus) Bool(key string, val bool) Logger
- func (lr *Logrus) Clone() Logger
- func (lr *Logrus) Debug(msg string)
- func (lr *Logrus) DebugMsg(msg string) LogMsg
- func (lr *Logrus) Err(err error, msg string)
- func (lr *Logrus) ErrMsg(err error, msg string) LogMsg
- func (lr *Logrus) F64(key string, val float64) Logger
- func (lr *Logrus) Fatal(msg string)
- func (lr *Logrus) FatalMsg(msg string) LogMsg
- func (lr *Logrus) I64(key string, val int64) Logger
- func (lr *Logrus) Info(msg string)
- func (lr *Logrus) InfoMsg(msg string) LogMsg
- func (lr *Logrus) Labels(labels map[string]interface{}) Logger
- func (lr *Logrus) Panic(msg string)
- func (lr *Logrus) PanicMsg(msg string) LogMsg
- func (lr *Logrus) Str(key, val string) Logger
- func (lr *Logrus) Trace(msg string)
- func (lr *Logrus) TraceMsg(msg string) LogMsg
- func (lr *Logrus) Warn(msg string)
- func (lr *Logrus) WarnMsg(msg string) LogMsg
- type LogrusConf
- type LogrusMsg
- type MultiLogMsg
- type MultiLogger
- func (l *MultiLogger) Bool(key string, val bool) Logger
- func (l *MultiLogger) Clone() Logger
- func (l *MultiLogger) Debug(msg string)
- func (l *MultiLogger) DebugMsg(msg string) LogMsg
- func (l *MultiLogger) Err(err error, msg string)
- func (l *MultiLogger) ErrMsg(err error, msg string) LogMsg
- func (l *MultiLogger) F64(key string, val float64) Logger
- func (l *MultiLogger) Fatal(msg string)
- func (l *MultiLogger) FatalMsg(msg string) LogMsg
- func (l *MultiLogger) I64(key string, val int64) Logger
- func (l *MultiLogger) Info(msg string)
- func (l *MultiLogger) InfoMsg(msg string) LogMsg
- func (l *MultiLogger) Labels(labels map[string]interface{}) Logger
- func (l *MultiLogger) Panic(msg string)
- func (l *MultiLogger) PanicMsg(msg string) LogMsg
- func (l *MultiLogger) Str(key, val string) Logger
- func (l *MultiLogger) Trace(msg string)
- func (l *MultiLogger) TraceMsg(msg string) LogMsg
- func (l *MultiLogger) Warn(msg string)
- func (l *MultiLogger) WarnMsg(msg string) LogMsg
- type NopLogger
- func (nl *NopLogger) Bool(key string, val bool) Logger
- func (nl *NopLogger) Clone() Logger
- func (nl *NopLogger) Debug(msg string)
- func (nl *NopLogger) DebugMsg(msg string) LogMsg
- func (nl *NopLogger) Err(err error, msg string)
- func (nl *NopLogger) ErrMsg(err error, msg string) LogMsg
- func (nl *NopLogger) F64(key string, val float64) Logger
- func (nl *NopLogger) Fatal(msg string)
- func (nl *NopLogger) FatalMsg(msg string) LogMsg
- func (nl *NopLogger) I64(key string, val int64) Logger
- func (nl *NopLogger) Info(msg string)
- func (nl *NopLogger) InfoMsg(msg string) LogMsg
- func (nl *NopLogger) Labels(labels map[string]interface{}) Logger
- func (nl *NopLogger) Panic(msg string)
- func (nl *NopLogger) PanicMsg(msg string) LogMsg
- func (nl *NopLogger) Str(key, val string) Logger
- func (nl *NopLogger) Trace(msg string)
- func (nl *NopLogger) TraceMsg(msg string) LogMsg
- func (nl *NopLogger) Warn(msg string)
- func (nl *NopLogger) WarnMsg(msg string) LogMsg
- type NopLoggerMsg
- type SentryConf
- type SentryLogger
- func (l *SentryLogger) Bool(key string, val bool) Logger
- func (l *SentryLogger) Clone() Logger
- func (l *SentryLogger) Debug(msg string)
- func (l *SentryLogger) DebugMsg(msg string) LogMsg
- func (l *SentryLogger) Err(err error, msg string)
- func (l *SentryLogger) ErrMsg(err error, msg string) LogMsg
- func (l *SentryLogger) F64(key string, val float64) Logger
- func (l *SentryLogger) Fatal(msg string)
- func (l *SentryLogger) FatalMsg(msg string) LogMsg
- func (l *SentryLogger) I64(key string, val int64) Logger
- func (l *SentryLogger) Info(msg string)
- func (l *SentryLogger) InfoMsg(msg string) LogMsg
- func (l *SentryLogger) Labels(labels map[string]interface{}) Logger
- func (l *SentryLogger) Panic(msg string)
- func (l *SentryLogger) PanicMsg(msg string) LogMsg
- func (l *SentryLogger) Req(req *http.Request) Logger
- func (l *SentryLogger) Str(key, val string) Logger
- func (l *SentryLogger) Trace(msg string)
- func (l *SentryLogger) TraceMsg(msg string) LogMsg
- func (l *SentryLogger) Warn(msg string)
- func (l *SentryLogger) WarnMsg(msg string) LogMsg
- type SentryLoggerMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CustomGraylogHook ¶
type CustomGraylogHook struct { *graylog.GraylogHook // contains filtered or unexported fields }
CustomGraylogHook adds a new layer over gemnasium Graylog hook to handle specific cases when trigerred.
func NewCustomGraylogHook ¶
func NewCustomGraylogHook(addr, fieldPrefix string) *CustomGraylogHook
NewCustomGraylogHook creates a hook to be added to an instance of logger.
type LogMsg ¶
type LogMsg interface { // Str adds a tag to the message of type string. Str(key, val string) LogMsg // I64 adds a tag to the message of type int64. I64(key string, val int64) LogMsg // F64 adds a tag to the message of type float64. F64(key string, val float64) LogMsg // Bool adds a tag to the message of type bool. Bool(key string, val bool) LogMsg // Send the message that has been constructed. Send() }
LogMsg is a message entry that can be built and is not sent until is explicitly told to be sent.
type Logger ¶
type Logger interface { // Trace logs a message with the trace level Trace(msg string) // Debug logs a message with the debug level Debug(msg string) // Info logs a message with the info level Info(msg string) // Warn logs a message with the warn level Warn(msg string) // Err logs a message with the error level Err(err error, msg string) // Fatal logs a message with the fatal level Fatal(msg string) // Panic logs a message with the fatal level Panic(msg string) // TraceMsg creates a LogMsg that inherit the logger // tags with a trace level. TraceMsg(msg string) LogMsg // DebugMsg creates a LogMsg that inherit the logger // tags with a debug level. DebugMsg(msg string) LogMsg // InfoMsg creates a LogMsg that inherit the logger // tags with a info level. InfoMsg(msg string) LogMsg // WarnMsg creates a LogMsg that inherit the logger // tags with a warn level. WarnMsg(msg string) LogMsg // ErrMsg creates a LogMsg that inherit the logger // tags with a error level. ErrMsg(err error, msg string) LogMsg // FatalMsg creates a LogMsg that inherit the logger // tags with a fatal level. FatalMsg(msg string) LogMsg // PanicMsg creates a LogMsg that inherit the logger // tags with a panic level. PanicMsg(msg string) LogMsg // Str adds a tag to the logger of type string Str(key, val string) Logger // I64 adds a tag to the logger of type int64 I64(key string, val int64) Logger // F64 adds a tag to the logger of type float64 F64(key string, val float64) Logger // Bool adds a tag to the logger of type bool Bool(key string, val bool) Logger // Labels sets labels for a logger in a batchl Labels(map[string]interface{}) Logger // Clone a logger, so from that point labels // will not be shared anymore. Clone() Logger }
Logger defines the interface to log data. Most of the calls return the same Logger interface so we can easily chain calls, like l.Str("foo", "bar").I64("count", 3).Trace("blab").
type LoggerBuilderFn ¶
type LoggerBuilderFn func() Logger
LoggerBuilderFn is the type required to instantiate a new Logger.
func NewLogrusBuilder ¶
func NewLogrusBuilder(conf *LogrusConf) (LoggerBuilderFn, func(), error)
NewLogrusBuilder returns a function to create Logrus loggers
func NewMultiLoggerBuilder ¶
func NewMultiLoggerBuilder(wrappedFns ...LoggerBuilderFn) LoggerBuilderFn
NewMultiLoggerBuilder returns a function to create MultiLogger loggers.
func NewNopLoggerBuilder ¶
func NewNopLoggerBuilder() LoggerBuilderFn
NewNopLoggerBuilder returns a function to construct NopLogger.
func NewSentryBuilder ¶
func NewSentryBuilder(conf *SentryConf) (LoggerBuilderFn, func(), error)
NewSentryBuilder returns a function to create Sentry loggers.
type Logrus ¶
type Logrus struct {
// contains filtered or unexported fields
}
Logrus is the logger to work with logrus.
func (*Logrus) DebugMsg ¶
DebugMsg creates a LogMsg that inherit the logger tags with a debug level.
func (*Logrus) FatalMsg ¶
FatalMsg creates a LogMsg that inherit the logger tags with a fatal level.
func (*Logrus) PanicMsg ¶
PanicMsg creates a LogMsg that inherit the logger tags with a panic level.
type LogrusConf ¶
type LogrusConf struct { // OutFileName is the file were we want to output the logs. OutFileName string // GraylogHost if not empty will report directly to graylog. GraylogHost string // GraylogFieldPrefix to add a prefix to all graylog logs. GraylogFieldPrefix string }
LogrusConf contains the values to configure a Logrus parser.
type LogrusMsg ¶
type LogrusMsg struct {
// contains filtered or unexported fields
}
LogrusMsg is a message entry that can be built and is not sent until is explicitly told to be sent.
type MultiLogMsg ¶
type MultiLogMsg struct {
// contains filtered or unexported fields
}
MultiLogMsg is a LogMsg that sends log mesages to multiple other loggers.
func (*MultiLogMsg) Bool ¶
func (lm *MultiLogMsg) Bool(key string, val bool) LogMsg
Bool adds a tag to the message of type bool.
func (*MultiLogMsg) F64 ¶
func (lm *MultiLogMsg) F64(key string, val float64) LogMsg
F64 adds a tag to the message of type float64.
func (*MultiLogMsg) I64 ¶
func (lm *MultiLogMsg) I64(key string, val int64) LogMsg
I64 adds a tag to the message of type int64.
func (*MultiLogMsg) Send ¶
func (lm *MultiLogMsg) Send()
Send the message that has been constructed.
func (*MultiLogMsg) Str ¶
func (lm *MultiLogMsg) Str(key, val string) LogMsg
Str adds a tag to the message of type string.
type MultiLogger ¶
type MultiLogger struct {
// contains filtered or unexported fields
}
MultiLogger is a logger that can wrap several other loggers an send the logs those multiple other instances.
func NewMultiLogger ¶
func NewMultiLogger(wrapped ...Logger) *MultiLogger
NewMultiLogger crates a new logger that will forward log messages to the list of wrapped loggers.
func (*MultiLogger) Bool ¶
func (l *MultiLogger) Bool(key string, val bool) Logger
Bool adds a tag to the logger of type bool
func (*MultiLogger) Debug ¶
func (l *MultiLogger) Debug(msg string)
Debug logs a message with the debug level
func (*MultiLogger) DebugMsg ¶
func (l *MultiLogger) DebugMsg(msg string) LogMsg
DebugMsg creates a LogMsg that inherit the logger tags with a debug level.
func (*MultiLogger) Err ¶
func (l *MultiLogger) Err(err error, msg string)
Err logs a message with the error level
func (*MultiLogger) ErrMsg ¶
func (l *MultiLogger) ErrMsg(err error, msg string) LogMsg
ErrMsg creates a LogMsg that inherit the logger tags with a error level.
func (*MultiLogger) F64 ¶
func (l *MultiLogger) F64(key string, val float64) Logger
F64 adds a tag to the logger of type float64
func (*MultiLogger) Fatal ¶
func (l *MultiLogger) Fatal(msg string)
Fatal logs a message with the fatal level
func (*MultiLogger) FatalMsg ¶
func (l *MultiLogger) FatalMsg(msg string) LogMsg
FatalMsg creates a LogMsg that inherit the logger tags with a fatal level.
func (*MultiLogger) I64 ¶
func (l *MultiLogger) I64(key string, val int64) Logger
I64 adds a tag to the logger of type int64
func (*MultiLogger) Info ¶
func (l *MultiLogger) Info(msg string)
Info logs a message with the info level
func (*MultiLogger) InfoMsg ¶
func (l *MultiLogger) InfoMsg(msg string) LogMsg
InfoMsg creates a LogMsg that inherit the logger tags with a info level.
func (*MultiLogger) Labels ¶
func (l *MultiLogger) Labels(labels map[string]interface{}) Logger
Labels sets labels for a logger in a batch
func (*MultiLogger) Panic ¶
func (l *MultiLogger) Panic(msg string)
Panic logs a message with the fatal level
func (*MultiLogger) PanicMsg ¶
func (l *MultiLogger) PanicMsg(msg string) LogMsg
PanicMsg creates a LogMsg that inherit the logger tags with a panic level.
func (*MultiLogger) Str ¶
func (l *MultiLogger) Str(key, val string) Logger
Str adds a tag to the logger of type string
func (*MultiLogger) Trace ¶
func (l *MultiLogger) Trace(msg string)
Trace logs a message with the trace level
func (*MultiLogger) TraceMsg ¶
func (l *MultiLogger) TraceMsg(msg string) LogMsg
TraceMsg creates a LogMsg that inherit the logger tags with a trace level.
func (*MultiLogger) Warn ¶
func (l *MultiLogger) Warn(msg string)
Warn logs a message with the warn level
func (*MultiLogger) WarnMsg ¶
func (l *MultiLogger) WarnMsg(msg string) LogMsg
WarnMsg creates a LogMsg that inherit the logger tags with a warn level.
type NopLogger ¶
type NopLogger struct { }
NopLogger is a logger that logs nothing.
func NewNopLogger ¶
func NewNopLogger() *NopLogger
NewNopLogger is a function to construct a NopLogger logger.
func (*NopLogger) DebugMsg ¶
DebugMsg creates a LogMsg that inherit the logger tags with a debug level.
func (*NopLogger) FatalMsg ¶
FatalMsg creates a LogMsg that inherit the logger tags with a fatal level.
func (*NopLogger) InfoMsg ¶
InfoMsg creates a LogMsg that inherit the logger tags with a info level.
func (*NopLogger) PanicMsg ¶
PanicMsg creates a LogMsg that inherit the logger tags with a panic level.
func (*NopLogger) TraceMsg ¶
TraceMsg creates a LogMsg that inherit the logger tags with a trace level.
type NopLoggerMsg ¶
type NopLoggerMsg struct { }
NopLoggerMsg is a log message that will send nothing.
func (*NopLoggerMsg) Bool ¶
func (lm *NopLoggerMsg) Bool(key string, val bool) LogMsg
Bool adds a tag to the message of type bool.
func (*NopLoggerMsg) F64 ¶
func (lm *NopLoggerMsg) F64(key string, val float64) LogMsg
F64 adds a tag to the message of type float64.
func (*NopLoggerMsg) I64 ¶
func (lm *NopLoggerMsg) I64(key string, val int64) LogMsg
I64 adds a tag to the message of type int64.
func (*NopLoggerMsg) Send ¶
func (lm *NopLoggerMsg) Send()
Send the message that has been constructed.
func (*NopLoggerMsg) Str ¶
func (lm *NopLoggerMsg) Str(key, val string) LogMsg
Str adds a tag to the message of type string.
type SentryConf ¶
type SentryConf struct { Dsn string AttachStacktrace bool SampleRate float64 Release string Environment string FlushTimeoutSecs int LevelThreshold string // the mininimum level required to be sent AllowedTags []string }
SentryConf contains the values to initialize a Sentry logger.
type SentryLogger ¶
type SentryLogger struct {
// contains filtered or unexported fields
}
SentryLogger implements a logger that sends messages to Sentry.
func (*SentryLogger) Bool ¶
func (l *SentryLogger) Bool(key string, val bool) Logger
Bool adds a tag to the logger of type bool
func (*SentryLogger) Debug ¶
func (l *SentryLogger) Debug(msg string)
Debug logs a message with the debug level
func (*SentryLogger) DebugMsg ¶
func (l *SentryLogger) DebugMsg(msg string) LogMsg
DebugMsg creates a LogMsg that inherit the logger tags with a debug level.
func (*SentryLogger) Err ¶
func (l *SentryLogger) Err(err error, msg string)
Err logs a message with the error level
func (*SentryLogger) ErrMsg ¶
func (l *SentryLogger) ErrMsg(err error, msg string) LogMsg
ErrMsg creates a LogMsg that inherit the logger tags with a error level.
func (*SentryLogger) F64 ¶
func (l *SentryLogger) F64(key string, val float64) Logger
F64 adds a tag to the logger of type float64
func (*SentryLogger) Fatal ¶
func (l *SentryLogger) Fatal(msg string)
Fatal logs a message with the fatal level
func (*SentryLogger) FatalMsg ¶
func (l *SentryLogger) FatalMsg(msg string) LogMsg
FatalMsg creates a LogMsg that inherit the logger tags with a fatal level.
func (*SentryLogger) I64 ¶
func (l *SentryLogger) I64(key string, val int64) Logger
I64 adds a tag to the logger of type int64
func (*SentryLogger) Info ¶
func (l *SentryLogger) Info(msg string)
Info logs a message with the info level
func (*SentryLogger) InfoMsg ¶
func (l *SentryLogger) InfoMsg(msg string) LogMsg
InfoMsg creates a LogMsg that inherit the logger tags with a info level.
func (*SentryLogger) Labels ¶
func (l *SentryLogger) Labels(labels map[string]interface{}) Logger
Labels sets labels for a logger in a batch
func (*SentryLogger) Panic ¶
func (l *SentryLogger) Panic(msg string)
Panic logs a message with the fatal level
func (*SentryLogger) PanicMsg ¶
func (l *SentryLogger) PanicMsg(msg string) LogMsg
PanicMsg creates a LogMsg that inherit the logger tags with a panic level.
func (*SentryLogger) Req ¶
func (l *SentryLogger) Req(req *http.Request) Logger
Req prepares a log to include http request information.
func (*SentryLogger) Str ¶
func (l *SentryLogger) Str(key, val string) Logger
Str adds a tag to the logger of type string
func (*SentryLogger) Trace ¶
func (l *SentryLogger) Trace(msg string)
Trace logs a message with the trace level
func (*SentryLogger) TraceMsg ¶
func (l *SentryLogger) TraceMsg(msg string) LogMsg
TraceMsg creates a LogMsg that inherit the logger tags with a trace level.
func (*SentryLogger) Warn ¶
func (l *SentryLogger) Warn(msg string)
Warn logs a message with the warn level
func (*SentryLogger) WarnMsg ¶
func (l *SentryLogger) WarnMsg(msg string) LogMsg
WarnMsg creates a LogMsg that inherit the logger tags with a warn level.
type SentryLoggerMsg ¶
type SentryLoggerMsg struct {
// contains filtered or unexported fields
}
SentryLoggerMsg implements a LogMessage that can be sent to Sentry.
func (*SentryLoggerMsg) Bool ¶
func (m *SentryLoggerMsg) Bool(key string, val bool) LogMsg
Bool adds a tag to the message of type bool.
func (*SentryLoggerMsg) F64 ¶
func (m *SentryLoggerMsg) F64(key string, val float64) LogMsg
F64 adds a tag to the message of type float64.
func (*SentryLoggerMsg) I64 ¶
func (m *SentryLoggerMsg) I64(key string, val int64) LogMsg
I64 adds a tag to the message of type int64.
func (*SentryLoggerMsg) Send ¶
func (m *SentryLoggerMsg) Send()
Send the message that has been constructed.
func (*SentryLoggerMsg) Str ¶
func (m *SentryLoggerMsg) Str(key, val string) LogMsg
Str adds a tag to the message of type string.