Converting to slog from fern, questions


Hi folks,

I’m interested in converting cernan to slog-rs from fern but have hit a couple of sticking points. You can see my in-progress work here: introduce_slog. There are two things that I haven’t managed to replicate:

  • startup time configuration of logging level: here
  • custom formatting of log message content: here

I’d really like to preserve the existing information I’m kicking out: module path, line origin, UTC timestamp, etc. The exact format doesn’t matter, of course, just so long as it’s there. It’s not clear to me if I can keep the module path without a whole lot of manual fiddling every time I make a new sub-logger.

The slog documentation does have an example on how to fiddle with log levels at runtime. I guess what I’m after, since I only want to set it once at startup, is a less manual way to get that kind of thing.

Anyway, thanks!


Example of startup time configuration of logging level:
You can easily created custom format for values using , but if you want completely customized formatting, you’ll have to write your own drain implementation that outputs exactly what you want, exactly where you want. Check slog-json source code for example how logging messages are outputed as Json, and slog-term for how terminal output format is implemented.

Generally I’d advise joinging slog gitter channel. More people are there and might help you.