]> git.proxmox.com Git - pve-guest-common.git/commitdiff
abstract migrate: avoid branched loop, move error-level into prefix
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Jan 2023 12:01:18 +0000 (13:01 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Jan 2023 12:01:18 +0000 (13:01 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/AbstractMigrate.pm

index 22a3fa744fe82ae855a98b8c5a7fa2bbd205839b..c337bcfe3fba35473038b505643fac2a9269ed9a 100644 (file)
@@ -19,15 +19,10 @@ my $msg2text = sub {
     return '' if !$msg;
 
     my $prefix = strftime("%F %H:%M:%S", localtime);
+    $prefix .= " ERROR:" if $level eq 'err';
 
     my $res = '';
-    foreach my $line (split (/\n/, $msg)) {
-       if ($level eq 'err') {
-           $res .= "$prefix ERROR: $line\n";
-       } else {
-           $res .= "$prefix $line\n";
-       }
-    }
+    $res .= "$prefix $_\n" for split (/\n/, $msg);
 
     return $res;
 };