You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All transport variants are implemented under a single class (Syslog extends Transport). Behaviour for different transport variants is driven by conditional if/else blocks (see, for example, sendDgram() and connectDgram()). This kind of approach makes the code hard to read and maintain.
Proposed solution
Leverage JavaScript object polymorphism! More specifically, code could be refactored into multiple internal classes implementing the common logging interface, e.g. at least UnixSocketSyslog, UDPSyslog and TCPSyslog. The Syslog constructor could parse the options and instantiate the appropriate subclass, so that existing consumers don't need to be updated.
The text was updated successfully, but these errors were encountered:
Problem
All transport variants are implemented under a single class (
Syslog extends Transport
). Behaviour for different transport variants is driven by conditional if/else blocks (see, for example,sendDgram()
andconnectDgram()
). This kind of approach makes the code hard to read and maintain.Proposed solution
Leverage JavaScript object polymorphism! More specifically, code could be refactored into multiple internal classes implementing the common logging interface, e.g. at least
UnixSocketSyslog
,UDPSyslog
andTCPSyslog
. TheSyslog
constructor could parse the options and instantiate the appropriate subclass, so that existing consumers don't need to be updated.The text was updated successfully, but these errors were encountered: