문제

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?)

도움이 되었습니까?

해결책

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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top