bt-agent: add option to redirect stdout and stderr to syslog
Add handlers for g_print() and g_printerr() methods to redirect output to syslog.
Add the corresponding option to use it.
Can't we just pipe to logger(1)?
Can't we just pipe to
logger(1)?
Hi @WhyNotHugo I've added --syslog/-s mainly for Buildroot, but it helps in any minimal image (BusyBox, Alpine, small containers, etc.):
- zero extra deps: no external logger(1) needed → smaller rootfs;
- no extra forks — logs go straight through syslog();
- correct severity (LOG_INFO/LOG_ERR) even if stdout/err are closed;
- optional, default-off.
It also integrates cleanly with systemd-journald because /dev/log is forwarded automatically. Thanks for feedback.
busybox includes logger(1).
Correct, busybox can include logger(1), but it’s an optional applet that many size-optimised Buildroot or container configs leave out (CONFIG_LOGGER option).
Besides, even when it exists, every log line goes through a separate fork()+exec() + see previous arguments.
So the option mainly removes a conditional dependency and gives tighter resource control, while staying completely optional.