[riot-devel] Lightweight Syslog Implementation

Robin robin at chilio.net
Thu Jul 4 14:59:36 CEST 2019


Hi All,

On 26.06.19 16:02, Robin wrote:
> As soon as I developed a concept and find time to implement it i will 
> come back to you. Most likely in late August.

Luckily i got some spare time to continue developing this PR [1] and i 
am curios what you are thinking so far.

What is already implemented:

- Implemented an additional LOG backend (log_mqueue), which spawns a 
thread that reads from a RIOT pipe. Calls to LOG() are written into this 
pipe and the thread dispatches the incoming LOG requests.

For the dispatch logic I use a very basic static array with function 
pointers. Messages are dispatched according to their facility value. By 
default the array is initialized to a default handler which itself is a 
wrapper to printf.

- Extending the syslog implementation to overwrite the dispatch array 
with a syslog handler function. Every facility != 0 is dispatched to the 
syslog implementation if the syslog module is enabled.

- Implementing four test cases which reflects the new LOG logic:

1. tests/log: LOG as implemented right now. Calls to LOG() uses the 
default implementation provided by log.h.

2. tests/log_mqueue: Uses the message queue backend as described above. 
LOG() request are dispatched to the default handler.

3. tests/log_mqueue_syslog: Overwrites the default handler with the 
syslog implementation. LOG() request with a facility != 0 are dispatched 
to syslog. LOG() request without facility value uses the default handler 
(printf).

4. tests/syslog: Syslog implementation without log_mqueue backend. LOG() 
request with any facility value are dispatched to the default LOG() 
wrapper as implemented in log.h (printf). Calls to syslog() uses the 
syslog implementation directly. This is used for compatibility reasons. 
A syslogd implementation is used to ship the logs over UDP.


I am curios if this reflects whats you described in the previous discussion?


The implementation needs a little bit of rework. Obvious problems right 
now are:

- Priority values in log.h and priority values in syslog.h are not the 
same by now. This could lead to Messages being accepted by LOG() but 
discarded by syslog(). Maybe i could change the implementation provided 
by log.h without loosing backwards compatibility.

- The dispatch logic needs further rethinking. By now an auto_init 
function plainly overwrites the whole dispatcher array with facilities 
!= 0. Also a linked list may be more feasible to allow more than a 
single module to attach onto a single facility value.

- The syslog implementation hooks itself to log_mqueue as soon as the 
log_mqueue module is used. This may should be more configurable.

- Configurability of queue sizes could be better.

- Missing Documentation.


[1] https://github.com/RIOT-OS/RIOT/pull/11362/


Robin



More information about the devel mailing list