[pve-devel] [PATCH manager v2] Fix #482: Add timestamps to backup creation log
Dominic Jäger
d.jaeger at proxmox.com
Tue Apr 16 11:57:10 CEST 2019
Adding timestamps to the log messages facilitates troubleshooting.
Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
v1->v2
Initially, I sticked to the rest of the code.
E.g. line 778 uses +1900 for the years aswell.
Now the more concise strftime is used.
PVE/VZDump.pm | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 7fc69f98..14b000bd 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -11,6 +11,7 @@ use File::Path;
use PVE::RPCEnvironment;
use PVE::Storage;
use PVE::Cluster qw(cfs_read_file);
+use POSIX qw(strftime);
use Time::localtime;
use Time::Local;
use PVE::JSONSchema qw(get_standard_option);
@@ -833,7 +834,10 @@ sub exec_backup_task {
unlink $logfile;
- debugmsg ('info', "Starting Backup of VM $vmid ($vmtype)", $logfd, 1);
+ debugmsg ('info', "Starting Backup of VM $vmid ($vmtype)", $logfd, 1);
+ my $start_msg_time = localtime();
+ debugmsg ('info', "Backup started at "
+ .strftime("%Y-%m-%d %H:%M:%S", @$start_msg_time)."\n", $logfd);
$plugin->set_logfd ($logfd);
@@ -1045,17 +1049,21 @@ sub exec_backup_task {
my $delay = $task->{backuptime} = time () - $vmstarttime;
+ my $end_msg_time = localtime();
if ($err) {
$task->{state} = 'err';
$task->{msg} = $err;
debugmsg ('err', "Backup of VM $vmid failed - $err", $logfd, 1);
-
+ debugmsg ('info', "Backup failed at "
+ .strftime("%Y-%m-%d %H:%M:%S", @$end_msg_time)."\n", $logfd);
eval { $self->run_hook_script ('backup-abort', $task, $logfd); };
} else {
$task->{state} = 'ok';
my $tstr = format_time ($delay);
debugmsg ('info', "Finished Backup of VM $vmid ($tstr)", $logfd, 1);
+ debugmsg ('info', "Backup finished at "
+ .strftime("%Y-%m-%d %H:%M:%S", @$end_msg_time)."\n", $logfd);
}
close ($logfd) if $logfd;
--
2.11.0
More information about the pve-devel
mailing list