Documentation ¶
Index ¶
- type HookedLogger
- func (l *HookedLogger) AddHook(h log.Hook)
- func (l *HookedLogger) GetLevel() string
- func (l *HookedLogger) GetLogDest() string
- func (l *HookedLogger) IsDebug() bool
- func (l *HookedLogger) Reopen() error
- func (l *HookedLogger) SetLevel(level string)
- func (l *HookedLogger) WithConn(conn net.Conn) *log.Entry
- type Level
- type Logger
- type LoggerHook
- type LogrusHook
- type OutputOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HookedLogger ¶
type HookedLogger struct { // satisfy the log.FieldLogger interface *log.Logger // contains filtered or unexported fields }
Implements the Logger interface It's a logrus logger wrapper that contains an instance of our LoggerHook
func (*HookedLogger) AddHook ¶
func (l *HookedLogger) AddHook(h log.Hook)
AddHook adds a new logrus hook
func (*HookedLogger) GetLevel ¶
func (l *HookedLogger) GetLevel() string
GetLevel gets the current log level
func (*HookedLogger) GetLogDest ¶
func (l *HookedLogger) GetLogDest() string
GetLogDest Gets the file name
func (*HookedLogger) IsDebug ¶
func (l *HookedLogger) IsDebug() bool
func (*HookedLogger) Reopen ¶
func (l *HookedLogger) Reopen() error
Reopen closes the log file and re-opens it
func (*HookedLogger) SetLevel ¶
func (l *HookedLogger) SetLevel(level string)
SetLevel sets a log level, one of the LogLevels
type Level ¶
type Level uint8
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel )
The following are taken from logrus
type Logger ¶
type LoggerHook ¶
LoggerHook extends the log.Hook interface by adding Reopen() and Rename()
func NewLogrusHook ¶
func NewLogrusHook(dest string) (LoggerHook, error)
newLogrusHook creates a new hook. dest can be a file name or one of the following strings: "stderr" - log to stderr, lines will be written to os.Stdout "stdout" - log to stdout, lines will be written to os.Stdout "off" - no log, lines will be written to ioutil.Discard
type LogrusHook ¶
type LogrusHook struct {
// contains filtered or unexported fields
}
func (*LogrusHook) Fire ¶
func (hook *LogrusHook) Fire(entry *log.Entry) error
Fire implements the logrus Hook interface. It disables color text formatting if writing to a file
func (*LogrusHook) Levels ¶
func (hook *LogrusHook) Levels() []log.Level
Levels implements the logrus Hook interface
func (*LogrusHook) Reopen ¶
func (hook *LogrusHook) Reopen() error
Reopen closes and re-open log file descriptor, which is a special feature of this hook
type OutputOption ¶
type OutputOption int
const ( OutputStderr OutputOption = 1 + iota OutputStdout OutputOff OutputNull OutputFile )
func (OutputOption) String ¶
func (o OutputOption) String() string