Bugzilla – Attachment 105016 Details for
Bug 25493
Koha::Logger is not suitable for using as Mojo::Log
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25493: Make ->unhandled_exception use Koha::Logger
Bug-25493-Make--unhandledexception-use-KohaLogger.patch (text/plain), 2.45 KB, created by
Kyle M Hall (khall)
on 2020-05-18 12:58:33 UTC
(
hide
)
Description:
Bug 25493: Make ->unhandled_exception use Koha::Logger
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-05-18 12:58:33 UTC
Size:
2.45 KB
patch
obsolete
>From 425de807696a1cbceb5dc3c50eafc16ade135995 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 13 May 2020 17:17:21 -0300 >Subject: [PATCH] Bug 25493: Make ->unhandled_exception use Koha::Logger > >To test: >1. Edit the Koha/REST/V1/Cities.pm 'list' method adding > die("Nada"); before the render step. >2. Restart plack and try the endpoint >=> SUCCESS: The message is generic, but you see something is >logged in /var/log/koha/kohadev/api-error.log >3. Change die("Nada"); for a real exception like: > > use Koha::Exceptions; > Koha::Exceptions::DuplicateObject->throw("Nada"); >4. Repeat 2. >=> SUCCESS: The message is generic, but a meaningful text is added to >the logs. >5. Point your browser to the /api/v1/hola route from your dev > environment >=> FAIL: Wow, such a weird error >6. Apply this patch >7. Restart plack and repeat 2, 3 and 4 >=> SUCCESS: No behaviour change >8. Repeat 5 >=> SUCCESS: The regular Mojolicious 404 weird page >9. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/REST/Plugin/Exceptions.pm | 3 ++- > Koha/REST/V1.pm | 3 --- > 2 files changed, 2 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/Plugin/Exceptions.pm b/Koha/REST/Plugin/Exceptions.pm >index 9e5c5e5727..e9be043aa2 100644 >--- a/Koha/REST/Plugin/Exceptions.pm >+++ b/Koha/REST/Plugin/Exceptions.pm >@@ -69,7 +69,8 @@ sub register { > > my $message = "$method $path: unhandled exception $type\<\<$exception_string\>\>"; > >- $c->app->log->error("$message"); >+ my $logger = Koha::Logger->get({ interface => 'api' }); >+ $logger->error("$message"); > > $c->render( > status => 500, >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index 680b52cd67..af6bc886fa 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -40,8 +40,6 @@ Overloaded Mojolicious->startup method. It is called at application startup. > sub startup { > my $self = shift; > >- $self->log( Koha::Logger->get({ interface => 'api' }) ); >- > $self->hook( > before_dispatch => sub { > my $c = shift; >@@ -63,7 +61,6 @@ sub startup { > $self->types->type( mij => 'application/marc-in-json' ); > $self->types->type( marc => 'application/marc' ); > >- > my $secret_passphrase = C4::Context->config('api_secret_passphrase'); > if ($secret_passphrase) { > $self->secrets([$secret_passphrase]); >-- >2.24.2 (Apple Git-127)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25493
:
104852
|
105016
|
105100