bidding-system icon indicating copy to clipboard operation
bidding-system copied to clipboard

Logging framework

Open twinguy opened this issue 11 months ago • 6 comments

Need to finalize which golang logging framework to use. Logging in Go: A Comparison of the Top 9 Libraries is an excellent overview of current options.

twinguy avatar Jan 01 '25 18:01 twinguy

Phuslu/log Zerolog Zap

we can pick from these 3

Saigenix avatar Jan 01 '25 18:01 Saigenix

I have used Zerolog extensively with no issues or observed performance penalties.

Zerolog: +1

twinguy avatar Jan 01 '25 18:01 twinguy

Here is a sample Zerolog configuration along with the output:

logger := zerolog.New(
zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339},
).Level(zerolog.TraceLevel).With().Timestamp().Caller().Logger()

logger.Debug().Msg("Debugging...")
logger.Trace().Msg("Tracing...")
logger.Warn().Msg("Warning...")
logger.Error().Msg("Error...")

which results in the following output Screenshot

twinguy avatar Jan 01 '25 21:01 twinguy

this looks fine.

nabeelnazeer avatar Jan 02 '25 07:01 nabeelnazeer

We can use zerolog then

Saigenix avatar Jan 02 '25 11:01 Saigenix

Seems I'm a bit late for party, please allow me do self-recommandation, The article "Logging in Go: A Comparison of the Top 9 Libraries" is a bit unfair for phuslu/log, in our internal system (Yes, I am also a bidding system author), my logger is more suitable becuase

  1. phuslu/log is 0-allocs in printf style logging, others are at least 1-allocs
  2. phuslu/log is 0-allocs in runtime.Caller cases, others are at least 3-allocs, and much much slower.
  3. phuslu/log is 0-allocs in Any/Interface cases, others are at least 1-allocs
  4. phuslu/log filewriter has linux writerv support, this is only one of golang world, resulting 10x faster in heavy-load cases.
  5. phuslu/log console field is ordered, it's hard in zerolog, see https://github.com/rs/zerolog/issues/155#issuecomment-2094274149
  6. phuslu/log is the fastest (and much faster) in stdlog slog implementation, see https://madkins23.github.io/go-slog/index.html

Finally, as a log library invented because of the bidding system, please believe me that this implementation is the most suitable.

phuslu avatar Jan 05 '25 12:01 phuslu