From 1a3c3e22711c5427cb2c311f5b3a202d31944608 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Apr 2019 14:31:53 -0300 Subject: [PATCH] Bug 18205: (QA follow-up) Use 'api' Signed-off-by: Tomas Cohen Arazi --- C4/Context.pm | 2 +- Koha/Logger/Mojo.pm | 40 ++++++++++++++++++++-------------------- Koha/REST/V1.pm | 2 +- etc/log4perl.conf | 18 +++++++++--------- t/Koha/Logger/Mojo.t | 8 ++++---- t/db_dependent/Log.t | 12 ++++++------ 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 50de0b4109..ac910cf51a 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1029,7 +1029,7 @@ sub interface { if (defined $interface) { $interface = lc $interface; if ($interface eq 'opac' || $interface eq 'intranet' || $interface eq 'sip' || - $interface eq 'commandline' || $interface eq 'rest' ) { + $interface eq 'commandline' || $interface eq 'api' ) { $context->{interface} = $interface; } else { warn "invalid interface : '$interface'"; diff --git a/Koha/Logger/Mojo.pm b/Koha/Logger/Mojo.pm index 3b2e535043..19cd0519da 100644 --- a/Koha/Logger/Mojo.pm +++ b/Koha/Logger/Mojo.pm @@ -29,25 +29,25 @@ Koha::Logger::Mojo $c->app->log->warn( 'WARNING: Serious error encountered' ); EXAMPLE CONFIGS: - log4perl.logger.rest = ERROR, REST - log4perl.appender.REST=Log::Log4perl::Appender::File - log4perl.appender.REST.filename=__LOG_DIR__/rest.log - log4perl.appender.REST.create_at_logtime=true - log4perl.appender.REST.syswrite=true - log4perl.appender.REST.recreate=true - log4perl.appender.REST.mode=append - log4perl.appender.REST.layout=PatternLayout - log4perl.appender.REST.layout.ConversionPattern=[%d] [%p] %m %l %n - - log4perl.logger.rest.Mojolicious.Plugin.OpenAPI = WARN, REST - log4perl.appender.REST=Log::Log4perl::Appender::File - log4perl.appender.REST.filename=__LOG_DIR__/rest.log - log4perl.appender.REST.create_at_logtime=true - log4perl.appender.REST.syswrite=true - log4perl.appender.REST.recreate=true - log4perl.appender.REST.mode=append - log4perl.appender.REST.layout=PatternLayout - log4perl.appender.REST.layout.ConversionPattern=[%d] [%p] %m %l %n + log4perl.logger.api = ERROR, API + log4perl.appender.API=Log::Log4perl::Appender::File + log4perl.appender.API.filename=__LOG_DIR__/api.log + log4perl.appender.API.create_at_logtime=true + log4perl.appender.API.syswrite=true + log4perl.appender.API.recreate=true + log4perl.appender.API.mode=append + log4perl.appender.API.layout=PatternLayout + log4perl.appender.API.layout.ConversionPattern=[%d] [%p] %m %l %n + + log4perl.logger.api.Mojolicious.Plugin.OpenAPI = WARN, API + log4perl.appender.API=Log::Log4perl::Appender::File + log4perl.appender.API.filename=__LOG_DIR__/api.log + log4perl.appender.API.create_at_logtime=true + log4perl.appender.API.syswrite=true + log4perl.appender.API.recreate=true + log4perl.appender.API.mode=append + log4perl.appender.API.layout=PatternLayout + log4perl.appender.API.layout.ConversionPattern=[%d] [%p] %m %l %n =head1 DESCRIPTION @@ -99,7 +99,7 @@ sub get { Overloads MojoX::Log::Log4perl::_get_logger by optionally including interface and category. -For REST API, 'rest' should be the root category by default (defined in startup) +For REST API, 'api' should be the root category by default (defined in startup) =cut diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm index 6c678838c0..2645e28576 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -40,7 +40,7 @@ Overloaded Mojolicious->startup method. It is called at application startup. sub startup { my $self = shift; - C4::Context->interface('rest'); + C4::Context->interface('api'); $self->log(Koha::Logger::Mojo->get); diff --git a/etc/log4perl.conf b/etc/log4perl.conf index b64d3c7102..b2e60f0abe 100644 --- a/etc/log4perl.conf +++ b/etc/log4perl.conf @@ -12,12 +12,12 @@ log4perl.appender.OPAC.mode=append log4perl.appender.OPAC.layout=PatternLayout log4perl.appender.OPAC.layout.ConversionPattern=[%d] [%p] %m %l %n -log4perl.logger.rest = WARN, REST -log4perl.appender.REST=Log::Log4perl::Appender::File -log4perl.appender.REST.filename=__LOG_DIR__/rest.log -log4perl.appender.REST.create_at_logtime=true -log4perl.appender.REST.syswrite=true -log4perl.appender.REST.recreate=true -log4perl.appender.REST.mode=append -log4perl.appender.REST.layout=PatternLayout -log4perl.appender.REST.layout.ConversionPattern=[%d] [%p] %m %l %n +log4perl.logger.api = WARN, API +log4perl.appender.API=Log::Log4perl::Appender::File +log4perl.appender.API.filename=__LOG_DIR__/api.log +log4perl.appender.API.create_at_logtime=true +log4perl.appender.API.syswrite=true +log4perl.appender.API.recreate=true +log4perl.appender.API.mode=append +log4perl.appender.API.layout=PatternLayout +log4perl.appender.API.layout.ConversionPattern=[%d] [%p] %m %l %n diff --git a/t/Koha/Logger/Mojo.t b/t/Koha/Logger/Mojo.t index 0bdebca71b..c7c366cd97 100644 --- a/t/Koha/Logger/Mojo.t +++ b/t/Koha/Logger/Mojo.t @@ -37,17 +37,17 @@ use_ok('Koha::Logger::Mojo'); # Create test context my $config = { - 'log4perl.logger.rest' => 'ERROR, TEST', + 'log4perl.logger.api' => 'ERROR, TEST', 'log4perl.appender.TEST' => 'Log::Log4perl::Appender::TestBuffer', 'log4perl.appender.TEST.layout' => 'SimpleLayout', }; -C4::Context->interface('rest'); +C4::Context->interface('api'); t::lib::Mocks::mock_config('log4perl_conf', $config); subtest 'check inteface' => sub { plan tests => 1; - is(C4::Context->interface, 'rest', 'Using appropriate interface.'); + is(C4::Context->interface, 'api', 'Using appropriate interface.'); }; subtest 'get() tests' => sub { @@ -62,7 +62,7 @@ subtest 'Test configuration effectiveness' => sub { plan tests => 6; get '/test' => sub { - package Koha::REST::V1::Test; # otherwise category would be rest.main + package Koha::REST::V1::Test; # otherwise category would be api.main $_[0]->app->log->error('Very problem'); $_[0]->app->log->warn('Such issue'); $_[0]->render(text => 'Hello World'); diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t index f96b439d42..f6ea161f91 100644 --- a/t/db_dependent/Log.t +++ b/t/db_dependent/Log.t @@ -125,10 +125,10 @@ subtest 'logaction(): interface is correctly logged' => sub { # Explicit interfaces $dbh->do("DELETE FROM action_logs;"); - C4::Context->interface( 'rest' ); - logaction( "MEMBERS", "MODIFY", 1, 'test info', 'rest'); + C4::Context->interface( 'api' ); + logaction( "MEMBERS", "MODIFY", 1, 'test info', 'api'); $logs = GetLogs(); - is( @{$logs}[0]->{ interface }, 'rest', 'Passed interface is respected (rest)'); + is( @{$logs}[0]->{ interface }, 'api', 'Passed interface is respected (api)'); }; @@ -142,7 +142,7 @@ subtest 'GetLogs() respects interface filters' => sub { logaction( 'MEMBERS', 'MODIFY', 1, 'sip info', 'sip'); logaction( 'MEMBERS', 'MODIFY', 1, 'intranet info', 'intranet'); logaction( 'MEMBERS', 'MODIFY', 1, 'commandline info', 'commandline'); - logaction( 'MEMBERS', 'MODIFY', 1, 'rest info', 'rest'); + logaction( 'MEMBERS', 'MODIFY', 1, 'api info', 'api'); my $logs = scalar @{ GetLogs() }; is( $logs, 5, 'If no filter on interfaces is passed, all logs are returned'); @@ -159,8 +159,8 @@ subtest 'GetLogs() respects interface filters' => sub { $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['commandline']); is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly filtered (commandline)'); - $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['rest']); - is( @{$logs}[0]->{ interface }, 'rest', 'Interface correctly filtered (rest)'); + $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['api']); + is( @{$logs}[0]->{ interface }, 'api', 'Interface correctly filtered (api)'); }; -- 2.21.0