MCPcopy
hub / github.com/keploy/keploy / Write

Method Write

utils/log/logger.go:138–154  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

136}
137
138func (w *redactingWriter) Write(p []byte) (int, error) {
139 r := loadRedactor()
140 if r == nil {
141 return w.inner.Write(p)
142 }
143 // RedactEncoded is byte-length-preserving (Redact substitutes within
144 // the same character class), so the redacted slice has len(p). We
145 // transform p, hand the result to the sink, and report success in
146 // terms of p — the io.Writer contract is "wrote n bytes from p"; the
147 // transformation is invisible to the caller. On error, return 0 so
148 // the caller can retry the original p without trying to reason about
149 // partial writes of redacted text.
150 if _, err := w.inner.Write([]byte(r.RedactEncoded(string(p)))); err != nil {
151 return 0, err
152 }
153 return len(p), nil
154}
155
156func (w *redactingWriter) Sync() error {
157 return w.inner.Sync()

Callers

nothing calls this directly

Calls 3

loadRedactorFunction · 0.85
WriteMethod · 0.65
RedactEncodedMethod · 0.65

Tested by

no test coverage detected