zerolog icon indicating copy to clipboard operation
zerolog copied to clipboard

How's the performance of ConsoleWriter?

Open ten2ten2 opened this issue 4 years ago • 3 comments

Could you please provide the performance of ConsoleWriter as well in the Benchmarks section? How is it compare to the performance of zap (sugared)?

ten2ten2 avatar Nov 22 '21 18:11 ten2ten2

The consol writer is not performance optimized and is not meant to be used in production. You can PR a benchmark if you need it.

I'm not sure to understand the comparison with zap sugared.

rs avatar Nov 22 '21 20:11 rs

I have re-wrote a zerolog like logger and have a new console writer with performance improvment.

https://github.com/phuslu/log/blob/master/console.go#L15-L24 said,

// ConsoleWriter parses the JSON input and writes it in a colorized, human-friendly format to Writer.
// IMPORTANT: Don't use ConsoleWriter on critical path of a high concurrency and low latency application.
//
// Default output format:
//     {Time} {Level} {Goid} {Caller} > {Message} {Key}={Value} {Key}={Value}
//
// Note: The performance of ConsoleWriter is not good enough, because it will
// parses JSON input into structured records, then output in a specific order.
// Roughly 2x faster than logrus.TextFormatter, 0.8x fast as zap.ConsoleEncoder,
// and 5x faster than zerolog.ConsoleWriter.

phuslu avatar Jun 16 '22 03:06 phuslu