[pve-devel] applied: [PATCH firewall 2/2] log errors encountered by the daemon to syslog

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Apr 10 15:04:51 CEST 2017


On Wed, Mar 22, 2017 at 12:53:34PM +0100, Wolfgang Bumiller wrote:
> ---
> This has been bugging me for way too long. That whole $verbose/$noerr
> mess needs to be cleaned up at some point.
> 
>  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.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list