Documentation ¶
Overview ¶
Package logger contains Funnel's logging code.
Index ¶
- Constants
- func Debug(msg string, args ...interface{})
- func PrintSimpleError(err error)
- func SetGRPCLogger(l *Logger)
- type Config
- type Formatter
- type JSONFormatConfig
- type Logger
- func (l *Logger) Configure(conf Config)
- func (l *Logger) Debug(msg string, args ...interface{})
- func (l *Logger) Discard()
- func (l *Logger) Error(msg string, args ...interface{})
- func (l *Logger) Info(msg string, args ...interface{})
- func (l *Logger) SetFormatter(f Formatter)
- func (l *Logger) SetLevel(lvl string)
- func (l *Logger) SetOutput(o io.Writer)
- func (l *Logger) Sub(ns string) *Logger
- func (l *Logger) Warn(msg string, args ...interface{})
- func (l *Logger) WithFields(args ...interface{}) *Logger
- type TextFormatConfig
Constants ¶
const ( DebugLevel = "debug" InfoLevel = "info" ErrorLevel = "error" WarnLevel = "warn" )
Log levels
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(msg string, args ...interface{})
Debug logs debug messages to a global logger.
func PrintSimpleError ¶
func PrintSimpleError(err error)
PrintSimpleError prints out an error message with a red "ERROR:" prefix.
Types ¶
type Config ¶
type Config struct { Level string Formatter string OutputFile string JSONFormat JSONFormatConfig TextFormat TextFormatConfig }
Config provides configuration for a logger.
func DebugConfig ¶
func DebugConfig() Config
DebugConfig returns a Config instance with default values useful for testing/debugging.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config instance with default values.
type JSONFormatConfig ¶
JSONFormatConfig provides configuration for the JSON logger format.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger handles structured, configurable application logging.
func (*Logger) Debug ¶
Debug logs a debug message.
After the first argument, arguments are key-value pairs which are written as structured logs.
log.Debug("Some message here", "key1", value1, "key2", value2)
func (*Logger) Discard ¶
func (l *Logger) Discard()
Discard configures the logger to discard all logs.
func (*Logger) Error ¶
Error logs an error message
After the first argument, arguments are key-value pairs which are written as structured logs.
log.Error("Some message here", "key1", value1, "key2", value2)
Error has a two-argument version that can be used as a shortcut.
err := startServer() log.Error("Couldn't start server", err)
func (*Logger) Info ¶
Info logs an info message
After the first argument, arguments are key-value pairs which are written as structured logs.
log.Info("Some message here", "key1", value1, "key2", value2)
func (*Logger) SetFormatter ¶
SetFormatter sets the formatter of the logger.
func (*Logger) Sub ¶
Sub is a shortcut for l.WithFields("ns", ns), it creates a new logger which inherits the parent's configuration but changes the namespace.
func (*Logger) Warn ¶
Warn logs an warning message
After the first argument, arguments are key-value pairs which are written as structured logs.
log.Info("Some message here", "key1", value1, "key2", value2)
func (*Logger) WithFields ¶
WithFields returns a new Logger instance with the given fields added to all log messages.
type TextFormatConfig ¶
type TextFormatConfig struct { // Set to true to bypass checking for a TTY before outputting colors. ForceColors bool // Force disabling colors. DisableColors bool // Disable timestamp logging. useful when output is redirected to logging // system that already adds timestamps. DisableTimestamp bool // Enable logging the full timestamp when a TTY is attached instead of just // the time passed since beginning of execution. FullTimestamp bool // TimestampFormat to use for display when a full timestamp is printed TimestampFormat string // The fields are sorted by default for a consistent output. For applications // that log extremely frequently and don't use the JSON formatter this may not // be desired. DisableSorting bool Indent string }
TextFormatConfig provides configuration for the text logger format.