[pve-devel] [PATCH manager 2/2] use log method from base VZDump::Plugin

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Sep 13 10:30:15 CEST 2017


we copied our log method over there to resolve a cyclic dependency,
now use it here to reduce code duplication.
As we are below pve-guest-common in the dpendency hierachy we may use
it, but it does not may (or at least should) use us.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/VZDump.pm | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 004672d1..ef20e679 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -4,11 +4,10 @@ use strict;
 use warnings;
 use Fcntl ':flock';
 use PVE::Exception qw(raise_param_exc);
-use PVE::SafeSyslog;
 use IO::File;
 use IO::Select;
 use IPC::Open3;
-use POSIX qw(strftime);
+use POSIX;
 use File::Path;
 use PVE::RPCEnvironment;
 use PVE::Storage;
@@ -18,6 +17,7 @@ use Time::Local;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::HA::Env::PVE2;
 use PVE::HA::Config;
+use PVE::VZDump::Plugin;
 
 my @posix_filesystems = qw(ext3 ext4 nfs nfs4 reiserfs xfs);
 
@@ -198,29 +198,10 @@ foreach my $plug (@pve_vzdump_classes) {
 
 # helper functions
 
-my $debugstattxt = {
-    err =>  'ERROR:',
-    info => 'INFO:',
-    warn => 'WARN:',
-};
-
 sub debugmsg {
     my ($mtype, $msg, $logfd, $syslog) = @_;
 
-    chomp $msg;
-
-    return if !$msg;
-
-    my $pre = $debugstattxt->{$mtype} || $debugstattxt->{'err'};
-
-    my $timestr = strftime ("%F %H:%M:%S", CORE::localtime);
-
-    syslog ($mtype eq 'info' ? 'info' : 'err', "$pre $msg") if $syslog;
-
-    foreach my $line (split (/\n/, $msg)) {
-	print STDERR "$pre $line\n";
-	print $logfd "$timestr $pre $line\n" if $logfd;
-    }
+    PVE::VZDump::Plugin::debugmsg(@_);
 }
 
 sub run_command {
-- 
2.11.0





More information about the pve-devel mailing list