Exa-Networks / exabgp

The BGP swiss army knife of networking
Other
2.09k stars 448 forks source link

syslog customization & logging leaves a bit to be desired #1122

Open he32 opened 2 years ago

he32 commented 2 years ago

With reference to issue #1121, this specific issue concentrates on the logging done by exabgp, perhaps first and foremost when it is run as a daemon.

It does appear that the following holds true:

How did I find this out? Looking at the system call trace, of course:

 15588  15588 python3.10 GIO   fd 3 wrote 64 bytes
       "<15>Created PIDfile /var/run/exabgp/exabgp.pid with value 15588\0"
...
 15588  15588 python3.10 GIO   fd 3 wrote 38 bytes
       "<15>initialising connection to peer-2\0"
...
 15588  15588 python3.10 GIO   fd 3 wrote 38 bytes
       "<15>initialising connection to peer-1\0"

etc. while the healthcheck module which runs as a separate process logs

 15063  15063 python3.10 GIO   fd 3 wrote 71 bytes
       "<30>healthcheck-resolver[15063]: send announces for UP state to ExaBGP\
        \0"

15 = 8+7, and 8 is 1x8 and 1 is "user", and 7 is "debug". 30 = 24+6, and 24 is 3x8 and 3 is "daemon", and 6 is "info".

he32 commented 2 years ago

Oh, yes, I should have said: this testing & observations is done with ExaBGP version 4.2.21.

he32 commented 2 years ago

And ... in the current exabgp code off github (substantially different from 4.2.21, at least in the logging department), I find in src/exabgp/logger/handler.py:

def _syslog(**kwargs):
    formating = kwargs.get('format', SHORT)
    handler = handlers.SysLogHandler(
        address=kwargs.get('address', '/dev/log'),
        facility=kwargs.get('facility', 'syslog'),
    )

Does that mean that the default facility is now syslog? That doesn't match well with the comment in <sys/syslog.h>:

#define LOG_SYSLOG      (5<<3)  /* messages generated internally by syslogd */
thomas-mangin commented 2 years ago

I am happy to change the way syslog works to be clearer and follow the expectation of users.

I believe the team uses stdout myself and it has been years since I have been a UNIX admin so I am a bit rusty.

If you have suggestions, I am happy to implement them.