[PATCH] Bugfix: svlogd does not apply pattern match options when using timestamps

Anuj Patel anuj.patel at meraki.net
Thu Nov 1 03:09:03 UTC 2018


Svlogd reads an optional config file that can be used to select/deselect
patterns when logging. This feature was not working when using the
timestamping option as well (svlogd -tt LOGDIR). Svlogd was including the
timestamp when trying to apply pattern matches. According to the svlogd
docs, http://smarden.org/runit/svlogd.8.html, timestamps should not be
considered part of the log message.

The cause of the issue was that "line" in the code was referring to a
global buffer of the log data. When timestamping was enabled we would push
an additional 26 bytes of timestamp data to the front of the buffer and
increment the lineptr pointer in main by 26 bytes. However we don't use
lineptr when calling logmatch. Instead we use the global "line" variable
which points to the beginning of the buffer with a timestamp.

This fixes the problem by passing the lineptr and linelen values from main
directly into logmatch rather than relying on the global "line" pointer
which does not get updated when we prepend the timestamp to the log message.

I've tested the change with and without timestamping (-tt) to confirm it
works in both cases on Ubuntu 16.04 and some embedded platforms I work on.
Any feedback is appreciated!

Thanks,
Anuj Patel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20181031/4c119fdb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-svlogd-pattern-matching-work-when-timestamping.patch
Type: application/octet-stream
Size: 1051 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20181031/4c119fdb/attachment.obj>


More information about the busybox mailing list