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

(-)a/C4/Reports/Guided.pm (+10 lines)
Lines 18-26 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 );
25
use Time::HiRes qw(gettimeofday tv_interval);
24
26
25
use C4::Context;
27
use C4::Context;
26
use C4::Koha qw( GetAuthorisedValues );
28
use C4::Koha qw( GetAuthorisedValues );
Lines 609-620 sub execute_query { Link Here
609
611
610
    $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id;
612
    $dbh->do( 'UPDATE saved_sql SET last_run = NOW() WHERE id = ?', undef, $report_id ) if $report_id;
611
613
614
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.query' } )
615
        ->info("Report $report_id : $sql, $offset, $limit") if $report_id;
616
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.start' } )
617
        ->info("Report starting: $report_id") if $report_id;
618
612
    my $sth = $dbh->prepare($sql);
619
    my $sth = $dbh->prepare($sql);
613
    eval {
620
    eval {
614
        $sth->execute(@$sql_params, $offset, $limit);
621
        $sth->execute(@$sql_params, $offset, $limit);
615
    };
622
    };
616
    warn $@ if $@;
623
    warn $@ if $@;
617
624
625
    Koha::Logger->get( { prefix => 0, interface => 'reports', category => 'execute.time.end' } )
626
        ->info("Report finished: $report_id") if $report_id;
627
618
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
628
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
619
    return ( $sth );
629
    return ( $sth );
620
}
630
}
(-)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