From 7a3faf371e615350b3fee2946ebfd57c8214fe36 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 25 Aug 2022 23:59:42 +0000 Subject: [PATCH] Bug 22678: Use Koha::Logger for Mojolicious API logger Content-Type: text/plain; charset=utf-8 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 --- Koha/REST/V1.pm | 3 +++ 1 file changed, 3 insertions(+) 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.20.1