From b0dbfb214c54afc31ce6d955ef04b30d922bb342 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. --- 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