MCPcopy
hub / github.com/uber-go/zap / NewIncreaseLevelCore

Function NewIncreaseLevelCore

zapcore/increase_level.go:39–47  ·  view source on GitHub ↗

NewIncreaseLevelCore creates a core that can be used to increase the level of an existing Core. It cannot be used to decrease the logging level, as it acts as a filter before calling the underlying core. If level decreases the log level, an error is returned.

(core Core, level LevelEnabler)

Source from the content-addressed store, hash-verified

37// as a filter before calling the underlying core. If level decreases the log level,
38// an error is returned.
39func NewIncreaseLevelCore(core Core, level LevelEnabler) (Core, error) {
40 for l := _maxLevel; l >= _minLevel; l-- {
41 if !core.Enabled(l) && level.Enabled(l) {
42 return nil, fmt.Errorf("invalid increase level, as level %q is allowed by increased level, but not by existing core", l)
43 }
44 }
45
46 return &levelFilterCore{core, level}, nil
47}
48
49func (c *levelFilterCore) Enabled(lvl Level) bool {
50 return c.level.Enabled(lvl)

Callers 2

IncreaseLevelFunction · 0.92
TestIncreaseLevelFunction · 0.85

Calls 2

EnabledMethod · 0.65
ErrorfMethod · 0.65

Tested by 1

TestIncreaseLevelFunction · 0.68