[pve-devel] [RFC v2 common 1/2] REST environment: add static log_warn function
Fabian Ebner
f.ebner at proxmox.com
Wed Feb 16 08:34:09 CET 2022
Ping for this series
Am 29.10.21 um 13:16 schrieb Fabian Ebner:
> which avoids the need for the caller to check whether the environment
> was initialized or not.
>
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
>
> Changes from v1:
> * The static function now calls the class method, rather than the
> other way around. If the current environment is a derived class
> providing its own implementation of warn(), the static function
> will call that one.
>
> src/PVE/RESTEnvironment.pm | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
> index 189a6cd..bf10040 100644
> --- a/src/PVE/RESTEnvironment.pm
> +++ b/src/PVE/RESTEnvironment.pm
> @@ -712,6 +712,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) = @_;
>
More information about the pve-devel
mailing list