From 26f20f1f7e98195c0ef995c4983ea9cadedf8b2e Mon Sep 17 00:00:00 2001 From: Sven Nierlein Date: Tue, 12 Nov 2024 08:28:44 +0100 Subject: [PATCH] fix warning Can't call method "PRINT" on an undefined value during global destruction --- lib/Thruk/Utils/External.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Thruk/Utils/External.pm b/lib/Thruk/Utils/External.pm index f323edda4..c276d39a6 100644 --- a/lib/Thruk/Utils/External.pm +++ b/lib/Thruk/Utils/External.pm @@ -1360,6 +1360,10 @@ sub PRINTF { sub PRINT { my($self, @data) = @_; + return unless $self; + my $fh = $self->{'fh'}; + return unless $fh; + my $time = Thruk::Utils::Log::time_prefix(); chop($time); $time = $time.$self->{'prefix'} if $self->{'prefix'}; $time = $time." "; @@ -1367,7 +1371,6 @@ sub PRINT { my $line = join("", @data); $self->{'newline'} = ($line =~ m/\n$/mx) ? 1 : 0; - my $fh = $self->{'fh'}; if(!$last_newline && !$self->{'newline'}) { # continue printing, previous line did not end with a newline CORE::print($fh $line);