bluez-tools icon indicating copy to clipboard operation
bluez-tools copied to clipboard

bt-agent: add option to redirect stdout and stderr to syslog

Open corviv opened this issue 1 year ago • 4 comments

Add handlers for g_print() and g_printerr() methods to redirect output to syslog.

Add the corresponding option to use it.

corviv avatar Nov 06 '24 12:11 corviv

Can't we just pipe to logger(1)?

WhyNotHugo avatar Jul 01 '25 10:07 WhyNotHugo

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.

corviv avatar Jul 01 '25 10:07 corviv

busybox includes logger(1).

WhyNotHugo avatar Jul 01 '25 10:07 WhyNotHugo

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.

corviv avatar Jul 01 '25 11:07 corviv