Many new software for ' reason ' think STDOUT is a logging interface.
Of course level may become complex , and nothing stops the new
https://www.freedesktop.org/software/systemd/man/sd-daemon.html * no comment *
The prometheus package just uses the nice rcctl tool to daemonize and pipe
to logger , fixing level to info : Production ready !
(I'm poking around this because I am integrating VictoriaMetrics.)
Fun fact none of them follow the SD_* tag to level the log, prometheus
is doing heroku style log , Victoria something similar, no info on
actual level ...
I first though logger could be made SD_* compliant and did it , but those
go program don't even follow that ( they probably more upstart friendly )
I can send that patch , on -d it reads stdin but look for the <x> and
change level.
Logger is so basic , i fear any change would never made it into base
So i thought about a perl script , as perl is in base, like so:
------
# ls -l /usr/local/share/examples/prometheus/logger.pl
-rwxr--r-- 1 _prometheus wheel 246 Oct 19 17:35
/usr/local/share/examples/prometheus/logger.pl
------
[0]-[/home/VictoriaMetrics]
# cat /usr/local/share/examples/prometheus/logger.pl
#!/usr/bin/perl
use Sys::Syslog qw(:standard :macros);
openlog("prometheus", "pid", "daemon");
while (my $l = <>) {
$l =~ /level=(\w+)/;
my $ll = $1 ? $1 : "info";
$ll = ($ll eq "warn") ? "warning" : $ll;
syslog($ll, $l);
}
closelog();
------
and then the rc.start is like this :
------
rc_start() {
${rcexec} "${daemon} ${daemon_flags} < /dev/null 2>&1 | \
/usr/local/share/examples/prometheus/logger.pl"
}
------
I tried to inline the perl but it's just almost impossible to \ all
the $" etc.. correctly.
Maybe logger could have a -d hero and a -d sd to do that job, or it
just kept package base,
or a similar perl logger could be added so it shared for those new log
" method "
( I know ttyd is like that too )
I Hope to get some positive feedback on how to manage those log ,
and on pushing that for the package or going down the logger road
Best.
--
--
---------------------------------------------------------------------------------------------------------------------
Knowing is not enough; we must apply. Willing is not enough; we must do