mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
Fix restart and code review (#912)
On start the daemon may write an empty line. Log as warning non managed log level. Thanks Andrew .F. for pointers
This commit is contained in:
parent
f818ab497b
commit
a02a12f639
1 changed files with 13 additions and 9 deletions
|
@ -3,16 +3,20 @@ use Sys::Syslog qw(:standard :macros);
|
|||
|
||||
openlog($ARGV[0], "pid", "daemon");
|
||||
|
||||
my %lvl_map = (
|
||||
'panic' => LOG_EMERG,
|
||||
'fatal' => LOG_CRIT,
|
||||
'error' => LOG_ERR,
|
||||
'warn' => LOG_WARNING,
|
||||
'info' => LOG_INFO,
|
||||
);
|
||||
|
||||
while (my $l = <STDIN>) {
|
||||
my @d = split /\t/, $l;
|
||||
# go level : "INFO", "WARN", "ERROR", "FATAL", "PANIC":
|
||||
my $lvl = $d[0];
|
||||
$lvl = LOG_EMERG if ($lvl eq 'panic');
|
||||
$lvl = 'crit' if ($lvl eq 'fatal');
|
||||
$lvl = 'err' if ($lvl eq 'error');
|
||||
$lvl = 'warning' if ($lvl eq 'warn');
|
||||
chomp $d[2];
|
||||
syslog( $lvl, $d[2] );
|
||||
my ($lvl, undef, $message) = split /\t/, $_, 3;
|
||||
next unless $message;
|
||||
$lvl = $lvl_map{ lc $lvl } || LOG_WARNING;
|
||||
chomp $message;
|
||||
syslog( $lvl, $message );
|
||||
}
|
||||
|
||||
closelog();
|
||||
|
|
Loading…
Reference in a new issue