MCPcopy
hub / github.com/rs/zerolog / NewConsoleWriter

Function NewConsoleWriter

console.go:102–119  ·  view source on GitHub ↗

NewConsoleWriter creates and initializes a new ConsoleWriter.

(options ...func(w *ConsoleWriter))

Source from the content-addressed store, hash-verified

100
101// NewConsoleWriter creates and initializes a new ConsoleWriter.
102func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter {
103 w := ConsoleWriter{
104 Out: os.Stdout,
105 TimeFormat: consoleDefaultTimeFormat,
106 PartsOrder: consoleDefaultPartsOrder(),
107 }
108
109 for _, opt := range options {
110 opt(&w)
111 }
112
113 // Fix color on Windows
114 if w.Out == os.Stdout || w.Out == os.Stderr {
115 w.Out = colorable.NewColorable(w.Out.(*os.File))
116 }
117
118 return w
119}
120
121// Write transforms the JSON input with formatters and appends to w.Out.
122func (w ConsoleWriter) Write(p []byte) (n int, err error) {

Callers 5

ExampleNewConsoleWriterFunction · 0.92
TestConsoleWriterFunction · 0.92
mainFunction · 0.92
TestTestWriterFunction · 0.85

Calls 1

consoleDefaultPartsOrderFunction · 0.85

Tested by 4

ExampleNewConsoleWriterFunction · 0.74
TestConsoleWriterFunction · 0.74
TestTestWriterFunction · 0.68