From 63eec05cb8aa8b3763ddc51cc3696392ae0e62e0 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 29 Aug 2022 09:58:38 +0000 Subject: [PATCH] Bug 22678: Replace a few unneeded Koha::Logger calls Content-Type: text/plain; charset=utf-8 We have Koha::Logger via the Mojo app now. Test plan: Run perl t/db_dependent/api/v1/unhandled_exceptions.t Your plack-api-error.log should contain something like: [2022/08/29 12:15:25] [ERROR] DELETE /api/v1/patrons/1052: unhandled exception (Koha::Exception)<> Signed-off-by: Marcel de Rooy --- Koha/REST/Plugin/Exceptions.pm | 4 +--- Koha/REST/Plugin/PluginRoutes.pm | 8 +++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm index b069711596..fd28d67e7f 100644 --- a/Koha/REST/Plugin/Exceptions.pm +++ b/Koha/REST/Plugin/Exceptions.pm @@ -18,7 +18,6 @@ package Koha::REST::Plugin::Exceptions; use Modern::Perl; use Scalar::Util qw( blessed ); -use Koha::Logger; use Mojo::Base 'Mojolicious::Plugin'; @@ -69,8 +68,7 @@ sub register { my $message = "$method $path: unhandled exception $type\<\<$exception_string\>\>"; - my $logger = Koha::Logger->get({ interface => 'api' }); - $logger->error("$message"); + $c->app->log->error( "$message" ); $c->render( status => 500, diff --git a/Koha/REST/Plugin/PluginRoutes.pm b/Koha/REST/Plugin/PluginRoutes.pm index e626a179b8..c275f2578c 100644 --- a/Koha/REST/Plugin/PluginRoutes.pm +++ b/Koha/REST/Plugin/PluginRoutes.pm @@ -21,7 +21,6 @@ use Mojo::Base 'Mojolicious::Plugin'; use Koha::Exceptions::Plugin; use Koha::Plugins; -use Koha::Logger; use Clone qw( clone ); use JSON::Validator::Schema::OpenAPIv2; @@ -57,7 +56,7 @@ sub register { ); foreach my $plugin ( @plugins ) { - $spec = $self->inject_routes( $spec, $plugin, $validate ); + $spec = $self->inject_routes( $spec, $plugin, $validate, $app->log ); } } @@ -70,7 +69,7 @@ sub register { =cut sub inject_routes { - my ( $self, $spec, $plugin, $validate ) = @_; + my ( $self, $spec, $plugin, $validate, $logger ) = @_; return merge_spec( $spec, $plugin ) unless $validate; @@ -91,8 +90,7 @@ sub inject_routes { catch { my $error = $_; my $class = ref $plugin; - my $logger = Koha::Logger->get({ interface => 'api' }); - $logger->error("Plugin $class route injection failed: $error"); + $logger->error( "Plugin $class route injection failed: $error" ); return $spec; }; } -- 2.20.1