MCPcopy
hub / github.com/keploy/keploy / ChangeColorEncoding

Function ChangeColorEncoding

utils/log/logger.go:327–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

325}
326
327func ChangeColorEncoding() (*zap.Logger, error) {
328 // For non-color mode, use the standard console encoder.
329 LogCfg.Encoding = "console"
330 LogCfg.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
331
332 // Build the core ourselves rather than using LogCfg.Build so the
333 // underlying WriteSyncer passes through wrapWriter. zap.Config.Build
334 // creates a stock ioCore whose sink we can't reach afterwards, which
335 // would mean the post-encode RedactEncoded pass never runs in
336 // --disable-ansi mode and non-string zap fields (Any/Binary/Reflect)
337 // would leak from that path.
338 encoder := zapcore.NewConsoleEncoder(LogCfg.EncoderConfig)
339 core := zapcore.NewCore(
340 encoder,
341 wrapWriter(zapcore.AddSync(os.Stdout)),
342 LogCfg.Level,
343 )
344 return reattachDebugFileSink(zap.New(newRedactingCore(core))), nil
345}
346
347// cappedWriteSyncer wraps a WriteSyncer and stops accepting bytes once
348// the running total of accepted bytes reaches cap. Past the cap, Write

Callers 1

ValidateFlagsMethod · 0.92

Calls 4

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

Tested by

no test coverage detected