MCPcopy
hub / github.com/keploy/keploy / ChangeLogLevel

Function ChangeLogLevel

utils/log/logger.go:274–291  ·  view source on GitHub ↗
(level zapcore.Level)

Source from the content-addressed store, hash-verified

272}
273
274func ChangeLogLevel(level zapcore.Level) (*zap.Logger, error) {
275 LogCfg.Level = zap.NewAtomicLevelAt(level)
276 if level == zap.DebugLevel {
277 LogCfg.DisableStacktrace = false
278 LogCfg.EncoderConfig.EncodeCaller = zapcore.ShortCallerEncoder
279 }
280
281 // Use our custom encoder when building
282 encoder := NewANSIConsoleEncoder(LogCfg.EncoderConfig)
283 core := zapcore.NewCore(
284 encoder,
285 wrapWriter(zapcore.AddSync(os.Stdout)),
286 LogCfg.Level,
287 )
288
289 logger := zap.New(newRedactingCore(core))
290 return reattachDebugFileSink(logger), nil
291}
292
293// RedirectToStderr re-creates the logger writing to stderr instead of stdout.
294// Use this when --json mode is active to prevent log lines from contaminating

Callers 2

ValidateFlagsMethod · 0.92

Calls 5

NewANSIConsoleEncoderFunction · 0.85
wrapWriterFunction · 0.85
newRedactingCoreFunction · 0.85
reattachDebugFileSinkFunction · 0.85
NewMethod · 0.65

Tested by 1