4 ms·
Logging is a cross-cutting concern, and most code bases employ a logger such that it violates the DRY principle. Any particular logger shouldn't be difficult to
by thangalin 4y ago
Logging is a cross-cutting concern, and most code bases employ a logger such that it violates the DRY principle. Any particular logger shouldn't be difficult to replace in a system. The issue is that developers conflate "logging" with "something happened that must be known." The former being a text message, the latter being an event. The advantage of using an event is that it decouples how the logging transpires from the information about the event. When done well, this can isolate logging to a single line of code in the code base, which is far easier to maintain than countless repetitious logger.debug(...) statements.
I've blogged about this to mixed reception:
https://dave.autonoma.ca/blog/2022/01/08/logging-code-smell/ https://dave.autonoma.ca/blog/2022/01/08/logging-code-smell/