From eedcb56462220b852ec68d7862c6fb9a0baa8fa8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 22 Mar 2017 12:53:34 +0100 Subject: [PATCH] log errors encountered by the daemon to syslog --- src/PVE/Firewall.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index 0535d78..cc81325 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -13,6 +13,7 @@ use PVE::Cluster; use PVE::ProcFSTools; use PVE::Tools qw($IPV4RE $IPV6RE); use PVE::Network; +use PVE::SafeSyslog; use File::Basename; use File::Path; use IO::File; @@ -2506,10 +2507,14 @@ sub parse_fw_rule { die "unable to parse rule parameters: $line\n" if length($line); $rule = verify_rule($rule, $cluster_conf, $fw_conf, $rule_env, 1); - if ($verbose && $rule->{errors}) { - warn "$prefix - errors in rule parameters: $orig_line\n"; + if ($rule->{errors}) { + # The verbose flag really means we're running from the CLI and want + # output on the console - in the other case we really want such errors + # to go into the syslog instead. + my $log = $verbose ? sub { warn @_ } : sub { syslog(err => @_) }; + $log->("$prefix - errors in rule parameters: $orig_line\n"); foreach my $p (keys %{$rule->{errors}}) { - warn " $p: $rule->{errors}->{$p}\n"; + $log->(" $p: $rule->{errors}->{$p}\n"); } } -- 2.39.2