]> git.proxmox.com Git - pve-common.git/commitdiff
REST environment: add static log_warn function
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 29 Oct 2021 11:16:22 +0000 (13:16 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Mar 2022 10:39:07 +0000 (11:39 +0100)
which avoids the need for the caller to check whether the environment
was initialized or not.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/RESTEnvironment.pm

index e50b7538ae2b23bf275cb231039924704e436e5b..1b2af088d7db0fc4e041f5ba77cac987a9565843 100644 (file)
@@ -715,6 +715,17 @@ sub fork_worker {
     return wantarray ? ($upid, $res) : $upid;
 }
 
+sub log_warn {
+    my ($message) = @_;
+
+    if ($rest_env) {
+       $rest_env->warn($message);
+    } else {
+       chomp($message);
+       print STDERR "WARN: $message\n";
+    }
+}
+
 sub warn {
     my ($self, $message) = @_;