Skip to content

Commit

Permalink
fix warning
Browse files Browse the repository at this point in the history
    Can't call method "PRINT" on an undefined value during global destruction
  • Loading branch information
sni committed Nov 12, 2024
1 parent f685790 commit 26f20f1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Thruk/Utils/External.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1360,14 +1360,17 @@ 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." ";
my $last_newline = $self->{'newline'};
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);
Expand Down

0 comments on commit 26f20f1

Please sign in to comment.