MCPcopy
hub / github.com/keploy/keploy / RedirectToStderr

Function RedirectToStderr

utils/log/logger.go:296–306  ·  view source on GitHub ↗

RedirectToStderr re-creates the logger writing to stderr instead of stdout. Use this when --json mode is active to prevent log lines from contaminating structured JSON on stdout.

()

Source from the content-addressed store, hash-verified

294// Use this when --json mode is active to prevent log lines from contaminating
295// structured JSON on stdout.
296func RedirectToStderr() (*zap.Logger, error) {
297 encoder := NewANSIConsoleEncoder(LogCfg.EncoderConfig)
298 core := zapcore.NewCore(
299 encoder,
300 wrapWriter(zapcore.AddSync(os.Stderr)),
301 LogCfg.Level,
302 )
303
304 logger := zap.New(newRedactingCore(core))
305 return reattachDebugFileSink(logger), nil
306}
307
308func AddMode(mode string) (*zap.Logger, error) {
309 cfg := LogCfg

Callers 1

ValidateFlagsMethod · 0.92

Calls 5

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

Tested by

no test coverage detected