From f292fb031158368c10601038fb2b10737641e176 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 27 Aug 2020 15:26:05 +0200 Subject: [PATCH] Bug 26145: Use Koha::Logger and display the full stacktrace --- Koha/REST/Plugin/PluginRoutes.pm | 4 +++- Koha/REST/V1.pm | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Koha/REST/Plugin/PluginRoutes.pm b/Koha/REST/Plugin/PluginRoutes.pm index 7643523409..1bd275948d 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; @@ -89,7 +90,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 d884e97fcc..2c24411ec4 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; @@ -102,9 +103,10 @@ sub startup { catch { # Validation of the complete spec failed. Resort to validation one-by-one # 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( @@ -135,7 +137,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