[pve-devel] [PATCH manager 3/3] pvestatd: log 'warn's in update_status

Thomas Lamprecht t.lamprecht at proxmox.com
Fri May 20 13:49:08 CEST 2016



On 05/20/2016 12:51 PM, Dietmar Maurer wrote:
> can we use the same code as in bin/pveproxy instead?

Yeah, sure it makes only sense, I oversaw that one.
We could add another daemon option also which would take care of that,
maybe a little overkill as this would not result in too much code reuse.

Opinions?

diff --git a/src/PVE/Daemon.pm b/src/PVE/Daemon.pm
index 9d72c32..b74b1fd 100644
--- a/src/PVE/Daemon.pm
+++ b/src/PVE/Daemon.pm
@@ -298,6 +298,17 @@ sub setup {
        }
     }
 
+    if ($self->{log_warnings}) {
+       $SIG{'__WARN__'} = sub {
+           my $err = $@;
+           my $t = $_[0];
+           chomp $t;
+           print STDERR "$t\n";
+           syslog('warning', "%s", $t);
+           $@ = $err;
+       };
+    }
+
     $self->{nodename} = PVE::INotify::nodename();
 }
 
@@ -465,6 +476,8 @@ sub new {
                $self->{$opt} = $value;
            } elsif ($opt eq 'setuid') {
                $self->{$opt} = $value;
+           } elsif ($opt eq 'log_warnings') {
+               $self->{$opt} = $value;
            } else {
                die "unknown daemon option '$opt'\n";
            }






More information about the pve-devel mailing list