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

(-)a/C4/Reports/Guided.pm (+7 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'})->info("Report $report_id : $sql, $offset, $limit");
615
    Koha::Logger->get({ prefix => 0, interface => 'reports', category => 'execute.time.start'})->info("Report starting: $report_id");
616
612
    my $sth = $dbh->prepare($sql);
617
    my $sth = $dbh->prepare($sql);
613
    eval {
618
    eval {
614
        $sth->execute(@$sql_params, $offset, $limit);
619
        $sth->execute(@$sql_params, $offset, $limit);
615
    };
620
    };
616
    warn $@ if $@;
621
    warn $@ if $@;
617
622
623
    Koha::Logger->get({ prefix => 0, interface => 'reports', category => 'execute.time.end'})->info("Report finished: $report_id");
624
618
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
625
    return ( $sth, { queryerr => $sth->errstr } ) if ($sth->err);
619
    return ( $sth );
626
    return ( $sth );
620
}
627
}
(-)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 => 11;
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
        "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