I’m (excitedly) upgrading a project to 0.16.0. For the most part it’s been pretty straightforward, there’s one issue I’m not sure how to best approach.
The project is a CLI and I would like it to log to the XDG-cache directory. To that end I have a helper which finds the correct directory based on how various XDG-environment variables are set. I’ve changed the helper to take an Environ.Map, but realize I can’t get my hands on the process’ Environ.Map because the logger is configured in std_options rather than main.
To be honest it never felt great finding/opening the logfile in logFn, given that means repeating that work for every line logged, so I can totally imagine that my approach here is the real problem. Either way, I’d be super grateful for tips towards achieving the goal of logging to a file based on XDG environment variables.
I would not put a writer to it in the global var, as if that would make it too easy to not flush in the logFn, which you usually want to do. logs that are too out of sync are less useful in some contexts.