There is some inconsistency in whether messages are logged.
log_debug, log_trace etc are macros in lirc_log.h which call logprintf only if the priority fits with the current log level.
logprintf, in lirc_log.h says "Write a message to log", and in lirc_log.c says "Prints the log request to the log, if the priority fits."
If logging to a file, logprintf only adds the message if the priority fits. If using syslog, it adds the message regardless of priority.
In addition, if using syslog, logprintf passes the prio parameter onto the vsyslog function without checking it first. If prio>7 (less important than LOG_DEBUG), it should be changed to LOG_DEBUG=7.
vsyslog takes the bottom 3 bits as the priority, so numbers greater than 7 wrap around.
LIRC_TRACE2=10 -> LOG_CRIT=2
LIRC_TRACE1=9 -> LOG_ALERT=1
LIRC_TRACE=8 -> LOG_EMERG=0
So LIRC's trace messages are becoming emergencies when passed to syslog.
It might also be useful to consider the cases where prio<3 .
The inconsistency is more or less by design, logprintf() is not really useful from user code - the logging interface is the log_* macros which checks loglevel and - -channel before actually doing any logging.
OTOH, the priority wrap-around is a clear bug fixed in [ebbafe] and [f3e10a] (release-0_9_4/master). Thanks for reporting!
I was thinking it would make more sense to check loglevel and channel in the logprintf function, rather than having the same conditional code written 8 times.
In any case, the comments are misleading (attached a patch for that).
Last edit: Helen Foster 2016-04-26
You are perfectly right about the comments. Fixed in [6bfe0f] and [2ebf3c] (release/master). Thanks for patches!
You might be right about the test as well. However, the traditional thinking is that the check to not do any logging should not generate a function call; hence the macro test (which also has hooks for log channel filtering).
Related
Commit: [2ebf3c]
Commit: [6bfe0f]
Last edit: Alec Leamas 2016-04-26