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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
c0920724ee
commit
490a056f59
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue