Documentation ¶
Overview ¶
Defines global context-aware logger. The default implementation uses logrus. This package registers "logger" config section on init(). The structure of the config section is expected to be un-marshal-able to Config struct.
Index ¶
- func Debug(ctx context.Context, args ...interface{})
- func Debugf(ctx context.Context, format string, args ...interface{})
- func Debugln(ctx context.Context, args ...interface{})
- func Error(ctx context.Context, args ...interface{})
- func Errorf(ctx context.Context, format string, args ...interface{})
- func Errorln(ctx context.Context, args ...interface{})
- func Fatal(ctx context.Context, args ...interface{})
- func Fatalf(ctx context.Context, format string, args ...interface{})
- func Fatalln(ctx context.Context, args ...interface{})
- func Info(ctx context.Context, args ...interface{})
- func Infof(ctx context.Context, format string, args ...interface{})
- func InfofNoCtx(format string, args ...interface{})
- func Infoln(ctx context.Context, args ...interface{})
- func IsLoggable(ctx context.Context, level Level) bool
- func Panic(ctx context.Context, args ...interface{})
- func Panicf(ctx context.Context, format string, args ...interface{})
- func Panicln(ctx context.Context, args ...interface{})
- func Print(ctx context.Context, args ...interface{})
- func Printf(ctx context.Context, format string, args ...interface{})
- func Println(ctx context.Context, args ...interface{})
- func SetConfig(cfg Config)
- func Warn(ctx context.Context, args ...interface{})
- func Warnf(ctx context.Context, format string, args ...interface{})
- func Warning(ctx context.Context, args ...interface{})
- func Warningf(ctx context.Context, format string, args ...interface{})
- func Warningln(ctx context.Context, args ...interface{})
- func Warnln(ctx context.Context, args ...interface{})
- func WithIndent(ctx context.Context, additionalIndent string) context.Context
- type Config
- type FormatterConfig
- type FormatterType
- type Level
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InfofNoCtx ¶
func InfofNoCtx(format string, args ...interface{})
InfofNoCtx logs a formatted message without context.
func IsLoggable ¶
Gets a value indicating whether logs at this level will be written to the logger. This is particularly useful to avoid computing log messages unnecessarily.
Types ¶
type Config ¶
type Config struct { // Determines whether to include source code location in logs. This might incurs a performance hit and is only // recommended on debug/development builds. IncludeSourceCode bool `json:"show-source" pflag:",Includes source code location in logs."` // Determines whether the logger should mute all logs (including panics) Mute bool `json:"mute" pflag:",Mutes all logs regardless of severity. Intended for benchmarks/tests only."` // Determines the minimum log level to log. Level Level `json:"level" pflag:",Sets the minimum logging level."` Formatter FormatterConfig `json:"formatter" pflag:",Sets logging format."` }
Global logger config.
type FormatterConfig ¶
type FormatterConfig struct {
Type FormatterType `json:"type" pflag:",Sets logging format type."`
}
type FormatterType ¶
type FormatterType = string
const ( FormatterJSON FormatterType = "json" FormatterText FormatterType = "text" )
type Level ¶
type Level = int
Level type.
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 )
These are the different logging levels.
Click to show internal directories.
Click to hide internal directories.