Bugzilla – Attachment 142318 Details for
Bug 22678
Set 'Koha::Logger' as the default mojo logger for the REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22678: Use Koha::Logger for Mojolicious API logger
Bug-22678-Use-KohaLogger-for-Mojolicious-API-logge.patch (text/plain), 1.85 KB, created by
Kyle M Hall
on 2022-10-21 10:38:01 UTC
(
hide
)
Description:
Bug 22678: Use Koha::Logger for Mojolicious API logger
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2022-10-21 10:38:01 UTC
Size:
1.85 KB
patch
obsolete
>From 18578f76bc5a0e7f185bfec79c0f47c7c4e88d25 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Thu, 25 Aug 2022 23:59:42 +0000 >Subject: [PATCH] Bug 22678: Use Koha::Logger for Mojolicious API logger > >This patch adds Koha::Logger as the Mojolicious logging object >for the API Mojolicious app. > >Test plan: >0. Apply the patch and koha-plack --restart kohadev >1. Add $c->app->log->debug('DEBUG') and >$c->app->log->warn('WARN') to a API controller like >Koha::REST::V1::Libraries >2. koha-plack --restart kohadev >3. Go to the API route tied to that API controller method >4. Look at /var/log/koha/kohadev/api-error.log >5. Note that 'WARN' appears but 'DEBUG' does not > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] Adding a context sub to Koha::Logger to get it working. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Logger.pm | 12 ++++++++++++ > Koha/REST/V1.pm | 3 +++ > 2 files changed, 15 insertions(+) > >diff --git a/Koha/Logger.pm b/Koha/Logger.pm >index bd1094c24b..e364c9cdb9 100644 >--- a/Koha/Logger.pm >+++ b/Koha/Logger.pm >@@ -189,6 +189,18 @@ sub debug_to_screen { > $self->{logger}->level( $Log::Log4perl::DEBUG ); > } > >+=head2 context >+ >+Mojolicous 8.23 added a "context" method, which Mojolicious will die >+on if it's missing from the logger. >+ >+=cut >+ >+sub context { >+ my $self = shift; >+ return $self; >+} >+ > =head1 AUTHOR > > Kyle M Hall, E<lt>kyle@bywatersolutions.comE<gt> >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index 62d326e0fd..79d73bbb87 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -43,6 +43,9 @@ Overloaded Mojolicious->startup method. It is called at application startup. > sub startup { > my $self = shift; > >+ my $logger = Koha::Logger->get({ interface => 'api' }); >+ $self->log($logger); >+ > $self->hook( > before_dispatch => sub { > my $c = shift; >-- >2.30.2
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 22678
:
139813
|
139816
|
139940
|
139942
|
139943
|
139944
| 142318 |
142319
|
142320