From 942a6fd012e764ab9a56f27991e5fe197f5eea5a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 3 Jan 2025 14:39:29 +0000 Subject: [PATCH] Bug 38818: Add diag option to t::lib::Mocks::Logger This patch adds a diag method to the Mocks::Logger object. This aids in debugging logging errors by simply outputting all log lines to screen in a diag statement. --- t/lib/Mocks/Logger.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/t/lib/Mocks/Logger.pm b/t/lib/Mocks/Logger.pm index 22c967a58c6..14504ba65fb 100644 --- a/t/lib/Mocks/Logger.pm +++ b/t/lib/Mocks/Logger.pm @@ -81,6 +81,26 @@ sub new { return $self; } +=head3 diag + + $logger->diag(); + +Method to output all recieved logs. + +=cut + +sub diag { + my ($self) = @_; + my $tb = $CLASS->builder; + $tb->diag("debug: \n " . join("\n ", @{ $self->{debug} })); + $tb->diag("error: \n " . join("\n ", @{ $self->{error} })); + $tb->diag("into: \n " . join("\n ", @{ $self->{info} })); + $tb->diag("fatal: \n " . join("\n ", @{ $self->{fatal} })); + $tb->diag("trace: \n " . join("\n ", @{ $self->{trace} })); + $tb->diag("warn: \n " . join("\n ", @{ $self->{warn} })); + return; +} + =head3 debug_is $logger->debug_is($expected); -- 2.47.1