Closed prx0 closed 6 months ago
I don't think making the log
function failable is a good idea. Then you have error handling all over the place.
As for the what do on error, it's depends (when doesn't it, right?). You can try logging using an alternative method, for example fall back to logging to standard error. If that doesn't work, it depends if it's critical for you to keep your logs.
For my own logger, which already logs to standard error, I also panic when I fail to log.
Closing as not planned.
Hi, I'm wondering about why the log function from the Log trait does not return a Result<T, E> ? https://docs.rs/log/0.4.20/log/trait.Log.html#tymethod.log
The current signature is:
If I cannot guarantee to write a log, should I panic instead of returning a Result::Err ? Or should I keep the error and do nothing here.
I see the authors of systemd-journald-loggers decided to panic in case of error. https://github.com/swsnr/systemd-journal-logger.rs/blob/main/src/lib.rs#L388
Is it the recommanded way to do ?
Thank you for reading