hashicorp/raft

Leveled Logging of Events

Closed this issue · 3 comments

Similar to #272 ,
I was thinking that would be good for Observability to implement a leveled log of events, since every log output to stderr is invoked like this:

`r.logger.Printf("[WARN] raft: no known peers, aborting election")`

I know that I can use it by providing a user-defined log to config struct and implement the logger interface to my own needs, but I think a more transparent approach would be a better idea. Being able to simply pass a log level to config, let's say "WARN", and it would only print entries of similar or higher priority (i.e. "WARN", "ERROR" and "FATAL"), greatly reducing interrupts to output unnecessary information in some cases.

I would like to know if there's any interested on this idea? I'll probably gonna implement that on my application some way or another, I was wondering if that's a necessary pull request.

Of course it would add a new layer of abstraction to every logger invocation, so a good performance log library is a must. I was thinking about Logrus or log15, do you have any other suggestions?

Hi @Lz-Gustavo ! Thanks for opening this. Leveled logging is definitely an upgrade we'd consider merging. Our library of choice for leveled logging is hc-log.

One note though. Consul (which uses hashicorp/raft) hasn't yet upgraded to hc-log, so we would just have to check that the API would be compatible before merging.

Does this give you sufficient information to answer your question? Thank you again!

Yea of course it does, thanks @RobbieMcKinstry for the suggestions! I'll definitely take a look about hc-log.

Closed by #321