Documentation ¶
Index ¶
- type Level
- type LevelEnabler
- type Logger
- type NopLogger
- func (n NopLogger) DPanicf(format string, params ...interface{})
- func (n NopLogger) Debugf(format string, params ...interface{})
- func (n NopLogger) Errorf(format string, params ...interface{})
- func (n NopLogger) Fatalf(format string, params ...interface{})
- func (n NopLogger) Infof(format string, params ...interface{})
- func (n NopLogger) Level() Level
- func (n NopLogger) Panicf(format string, params ...interface{})
- func (n NopLogger) Warnf(format string, params ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level int8
A Level is a logging priority. Higher levels are more important.
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel Level = iota - 1 // InfoLevel is the default logging priority. InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel // DPanicLevel logs are particularly important errors. In development the // logger panics after writing the message. DPanicLevel // PanicLevel logs a message, then panics. PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel // InvalidLevel is an invalid value for Level. // // Core implementations may panic if they see messages of this level. InvalidLevel = _maxLevel + 1 )
func LevelOf ¶
func LevelOf(enab LevelEnabler) Level
LevelOf reports the minimum enabled log level for the given LevelEnabler from Zap's supported log levels, or InvalidLevel if none of them are enabled.
A LevelEnabler may implement a 'Level() Level' method to override the behavior of this function.
func (c *core) Level() Level { return c.currentLevel }
It is recommended that [Core] implementations that wrap other cores use LevelOf to retrieve the level of the wrapped core. For example,
func (c *coreWrapper) Level() Level { return zapcore.LevelOf(c.wrappedCore) }
func ParseLevel ¶
ParseLevel parses a level based on the lower-case or all-caps ASCII representation of the log level. If the provided ASCII representation is invalid an error is returned.
This is particularly useful when dealing with text input to configure log levels.
func (Level) CapitalString ¶
CapitalString returns an all-caps ASCII representation of the log level.
func (*Level) Get ¶
func (l *Level) Get() interface{}
Get gets the level for the flag.Getter interface.
func (Level) MarshalText ¶
MarshalText marshals the Level to text. Note that the text representation drops the -Level suffix (see example).
func (*Level) UnmarshalText ¶
UnmarshalText unmarshals text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix (see example).
In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.
type LevelEnabler ¶
LevelEnabler decides whether a given logging level is enabled when logging a message.
Enablers are intended to be used to implement deterministic filters; concerns like sampling are better implemented as a Core.
Each concrete Level value implements a static LevelEnabler which returns true for itself and all higher logging levels. For example WarnLevel.Enabled() will return true for WarnLevel, ErrorLevel, DPanicLevel, PanicLevel, and FatalLevel, but return false for InfoLevel and DebugLevel.
type Logger ¶
type Logger interface { Debugf(format string, params ...interface{}) Infof(format string, params ...interface{}) Warnf(format string, params ...interface{}) Errorf(format string, params ...interface{}) Panicf(format string, params ...interface{}) DPanicf(format string, params ...interface{}) Fatalf(format string, params ...interface{}) Level() Level }
func NewNopLogger ¶
func NewNopLogger() Logger