Syslog
We are using xow in an embedded device to control our robot with the XBOX gamepad. We need log messages from xow for debugging, this is why the syslog facility is useful to us.
I hope this makes sense. If not, I'm open for another approach.
There's already an open PR implementing systemd logging. Maybe you could build upon that?
It's a part of this commit series: https://github.com/medusalix/xow/pull/100/commits
This also migrates to using the native syslog defines, so you could simply include syslog and remove those defines.
Thanks @kakra, indeed I missed that one ... I don't like much mixing PR that do too much different things. Since yours is about different things, I suggest reverting log related changes and I can apply them here, hope this makes sense.
Unfortunately, I don't use systemd and cannot test journald logging, I wil have to trust my poor blind programming skills.
Feel free to cherry pick the three log related commits, then rebase yours to these. It would make merging easier later. I'm not sure when @medusalix is able to review the merge requests but I think he's currently busy with the kernel-mode drivers.
I created these to beautify systemd logging (it didn't like the duplicate timestamp it was creating), and it has simple support for sending the log level through stderr/stdout by prepending a <L> marker with L being the level. So I figured we could simply discard the invented log levels and use syslog native log levels. I just didn't include the needed header so I defined them. But it should be a good base to start your PR with.
I don't like much mixing PR that do too much different things
Actually, the logging commits should have been a separate PR anyways, I added these later and it's unrelated to the original intent. So feel free to just pick them. I just didn't want to create another PR just for some eye-candy changes. These three commits fit much better into your PR.
Thanks @kakra for the feedbacks, I tried to backport your changes to my PR, rebasing doesn't seem straight forward as I used a different approach. Probably the best is that I wait until the other PR is merged and will adapt then with the next master.
Another point but thinking again, I'm pretty sure systemd has a syslog API and wondering if this is conecptually the same. Does outputing in systemd format as an advantage over using syslog interface?
Usually logging to systemd is as simple as writing to stdout/stderr, the output will be captured, prepended with a timestamp and redirected to the journal, optionally you can add a syslog level using <#> brackets in the front of each line. Daemons do not need to care about logging at all, they can just write to console. But you could just use syslog, too. Should work the same, at least if the distribution didn't force good old syslog for logging.