Private Tag Reporter
kiwifarms.net
- Joined
- Jul 7, 2024
After reading this and thinking through the problem, I've realized that, at least for non-trace-level logging, I should invert the dependency, and expose the logger as a wrapper... wait a second, is this a monadic pattern!?!?perhaps try separating the logging logic out from the program logic when possible
e.g. you have some code that runs other code and it is in charge of logging statistics and any thrown exceptions, and the inner code does not care about logging at all, except for maybe returning some extra statistics that could be logged
Code:
foo = function(params) ...
foo_with_logs = Logger(foo)
foo_with_logs(params)
//results in something like
//foo called with (params)
//foo result: (results)