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
Greetings! The below snippet sets up a syslog log handler, either using a unix socket or via UDP to localhost. This happens implicitly by pyeapi being in the import chain which can easily happen if you use Napalm. IMHO, a library should not make decisions about how to handle logs, that should be left up to the application consuming the library. In my case, this became a problem in a CI pipeline when the below code opened a socket. As a safeguard, we have a mechanism in place that throws an exception if a socket is opened by the code under test.
# Create a handler to log messages to syslog
if sys.platform == "darwin":
_syslog_handler = logging.handlers.SysLogHandler(address='/var/run/syslog')
else:
_syslog_handler = logging.handlers.SysLogHandler()
The text was updated successfully, but these errors were encountered:
hi @aedwardstx, however pyeapi makes lots of logs, updating it and leaving it w/o a handler will break lots of pyeapi deployments. How do you propose to handle _LOGGER then?
I spot checked a few similar libraries, netmiko, ncclient, napalm, and py-junos-eznc. All of them face similar challenges but none of them implement a log handler. They leave log handling up to the developer to implement as they see appropriate.
python/cpython#91070 indicates logging.handlers.SysLogHandler(address='/var/run/syslog') doesn't work on modern versions of MacOS.
Perhaps consider implementing a warning that the log handler is going away in a future version.
Greetings! The below snippet sets up a syslog log handler, either using a unix socket or via UDP to localhost. This happens implicitly by pyeapi being in the import chain which can easily happen if you use Napalm. IMHO, a library should not make decisions about how to handle logs, that should be left up to the application consuming the library. In my case, this became a problem in a CI pipeline when the below code opened a socket. As a safeguard, we have a mechanism in place that throws an exception if a socket is opened by the code under test.
https://github.com/arista-eosplus/pyeapi/blob/develop/pyeapi/utils.py#L47-L50
The text was updated successfully, but these errors were encountered: