View | Details | Raw Unified | Return to bug 35907
Collapse All | Expand All

(-)a/C4/Reports/Guided.pm (+9 lines)
Lines 18-23 package C4::Reports::Guided; Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
use CGI qw ( -utf8 );
22
use CGI qw ( -utf8 );
22
use Carp qw( carp croak );
23
use Carp qw( carp croak );
23
use JSON qw( from_json );
24
use JSON qw( from_json );
Lines 609-620 sub execute_query { Link Here
609
610
610
    $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id;
611
    $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id;
611
612
613
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.query' } )
614
        ->info("Report $report_id : $sql, $offset, $limit") if $report_id;
615
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.start' } )
616
        ->info("Report starting: $report_id") if $report_id;
617
612
    my $sth = $dbh->prepare($sql);
618
    my $sth = $dbh->prepare($sql);
613
    eval {
619
    eval {
614
        $sth->execute(@$sql_params, $offset, $limit);
620
        $sth->execute(@$sql_params, $offset, $limit);
615
    };
621
    };
616
    warn $@ if $@;
622
    warn $@ if $@;
617
623
624
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.end' } )
625
        ->info("Report finished: $report_id") if $report_id;
626
618
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
627
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
619
    return ( $sth );
628
    return ( $sth );
620
}
629
}
(-)a/Koha/Logger.pm (-1 / +4 lines)
Lines 51-63 BEGIN { Link Here
51
    Normally, the category should follow the current package and the interface
51
    Normally, the category should follow the current package and the interface
52
    should be set correctly via C4::Context.
52
    should be set correctly via C4::Context.
53
53
54
    If the category should not be prefixed if plack, set the param 'prefix' to 0.
54
=cut
55
=cut
55
56
56
sub get {
57
sub get {
57
    my ( $class, $params ) = @_;
58
    my ( $class, $params ) = @_;
58
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
59
    my $interface = $params ? ( $params->{interface} || C4::Context->interface ) : C4::Context->interface;
59
    my $category = $params ? ( $params->{category} || caller ) : caller;
60
    my $category = $params ? ( $params->{category} || caller ) : caller;
60
    my $l4pcat = ( C4::Context->psgi_env ? 'plack-' : q{} ) . $interface . '.' . $category;
61
    my $prefix = $params->{prefix} // 1;
62
63
    my $l4pcat = ( ( $prefix && C4::Context->psgi_env ) ? 'plack-' : q{} ) . $interface . '.' . $category;
61
64
62
    my $init = _init();
65
    my $init = _init();
63
    my $self = {};
66
    my $self = {};
(-)a/t/Logger.t (-2 / +16 lines)
Lines 27-33 use Test::Warn; Link Here
27
use Test::Exception;
27
use Test::Exception;
28
28
29
subtest 'Test01 -- Simple tests for Koha::Logger' => sub {
29
subtest 'Test01 -- Simple tests for Koha::Logger' => sub {
30
    plan tests => 10;
30
    plan tests => 13;
31
31
32
    my $ret;
32
    my $ret;
33
    t::lib::Mocks::mock_config('log4perl_conf', undef);
33
    t::lib::Mocks::mock_config('log4perl_conf', undef);
Lines 76-81 HERE Link Here
76
76
77
    Koha::Logger->clear_mdc();
77
    Koha::Logger->clear_mdc();
78
    is( Koha::Logger->get_mdc( 'foo' ), undef, "MDC value was cleared by clear_mdc" );
78
    is( Koha::Logger->get_mdc( 'foo' ), undef, "MDC value was cleared by clear_mdc" );
79
80
    is(
81
        Koha::Logger->get( { interface => 'cli', category => 'Test.Category' } )->category(), "cli.Test.Category",
82
        "Category is cli.Test.Category"
83
    );
84
    $ENV{'PLACK_ENV'} = 1;
85
    is(
86
        Koha::Logger->get( { interface => 'cli', category => 'Test.Category' } )->category(),
87
        "plack-cli.Test.Category", "Category under plack is is plack-cli.Test.Category"
88
    );
89
    is(
90
        Koha::Logger->get( { interface => 'cli', category => 'Test.Category', prefix => 0 } )->category(),
91
        "cli.Test.Category", "Category under plack with prefixing disabled is is cli.Test.Category"
92
    );
93
    delete $ENV{'PLACK_ENV'};
79
};
94
};
80
95
81
sub mytempfile {
96
sub mytempfile {
82
- 

Return to bug 35907