From 5f41964a17efb03b619c71cb38c2eea71dbc5163 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 27 Aug 2020 15:26:05 +0200 Subject: [PATCH] Bug 25504: Use Koha::Logger and display the full stacktrace --- Koha/REST/Plugin/PluginRoutes.pm | 4 +++- Koha/REST/V1.pm | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Koha/REST/Plugin/PluginRoutes.pm b/Koha/REST/Plugin/PluginRoutes.pm index 87bd2a6030..d434ee537d 100644 --- a/Koha/REST/Plugin/PluginRoutes.pm +++ b/Koha/REST/Plugin/PluginRoutes.pm @@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Plugin'; use Koha::Exceptions::Plugin; use Koha::Plugins; +use Koha::Logger; use Clone qw(clone); use Try::Tiny; @@ -91,7 +92,8 @@ sub inject_routes { catch { my $error = $_; my $class = ref $plugin; - warn "Plugin $class route injection failed: $error"; + my $logger = Koha::Logger->get({ interface => 'api' }); + $logger->error("Plugin $class route injection failed: $error"); return $spec; }; } diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm index a360162362..8942c30c2e 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious'; use C4::Context; +use Koha::Logger; use Carp; use JSON::Validator::OpenAPI::Mojolicious; use Try::Tiny; @@ -106,7 +107,8 @@ sub startup { # to catch bad ones. # JSON::Validator uses confess, so trim call stack from the message. - carp "Warning: Could not load REST API spec bundle: " . ($_ =~ /\A(.*?)$/ms)[0]; + my $logger = Koha::Logger->get({ interface => 'api' }); + $logger->error("Warning: Could not load REST API spec bundle: " . $_); try { $validator->load_and_validate_schema( @@ -138,7 +140,7 @@ sub startup { } catch { # JSON::Validator uses confess, so trim call stack from the message. - croak "Could not load REST API spec: " . ($_ =~ /\A(.*?)$/ms)[0]; + $logger->error("Warning: Could not load REST API spec bundle: " . $_); }; }; -- 2.20.1