Question

I have a logger that sends messages over the network. But when things fail, I want to know they are failing, so the network transport for the logger uses the logger to log errors.

How can I avoid this circular dependency? (and potentially infinite loop?)

Was it helpful?

Solution

Here are my conclusions:

  1. the logger transport should not use the logger, but instead directly use other adapters or just write to filesystem / console directly.
  2. If I think of logger and transport as different layers of the architecture, then transport clearly shouldn't need to use logger.
  3. Transports are part of the logger module, hence it doesn't make sense for it to think of logger as an external black box.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top