book icon indicating copy to clipboard operation
book copied to clipboard

Book: Logging

Open killercup opened this issue 7 years ago • 1 comments
trafficstars

  • log crate: macros with similar syntax to println
  • crate for actual log output -- which one? env_logger?

killercup avatar Aug 02 '18 17:08 killercup

I'm not a big fan of env_logger because you have to set a magic environment variable to get any output, which makes it difficult to integrate with the traditional --verbose and --quiet command-line arguments. The clap-verbosity-flag crate takes care of that, but that only works for one module; if you want to figure out what your program is really doing and turn up the logging verbosity everywhere, you're out of luck.

I've had good results with fern, although it doesn't integrate with clap out of the box.

Some command-line tools used as part of larger batch processes might have their logs fed into a rich data store like ElasticSearch or journald; in those cases, the slog crate and its ecosystem might be a better fit than the log crate, since it's designed around logging structured data rather than strings.

Screwtapello avatar Aug 03 '18 03:08 Screwtapello