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

(-)a/Koha/Logger.pm (-27 / +3 lines)
Lines 86-102 sub AUTOLOAD { Link Here
86
    my $method = $Koha::Logger::AUTOLOAD;
86
    my $method = $Koha::Logger::AUTOLOAD;
87
    $method =~ s/^Koha::Logger:://;
87
    $method =~ s/^Koha::Logger:://;
88
88
89
    if ( !exists $self->{logger} ) {
89
    if ( $self->{logger}->can($method) ) {    #use log4perl
90
90
        return $self->{logger}->$method($line);
91
        #do not use log4perl; no print to stderr
92
    }
93
    elsif ( !$self->_recheck_logfile ) {
94
        warn "Log file not writable for log4perl";
95
        warn "$method: $line" if $line;
96
    }
97
    elsif ( $self->{logger}->can($method) ) {    #use log4perl
98
        $self->{logger}->$method($line);
99
        return 1;
100
    }
91
    }
101
    else {                                       # we should not really get here
92
    else {                                       # we should not really get here
102
        warn "ERROR: Unsupported method $method";
93
        warn "ERROR: Unsupported method $method";
Lines 112-118 sub AUTOLOAD { Link Here
112
103
113
sub DESTROY { }
104
sub DESTROY { }
114
105
115
=head2 _init, _recheck_logfile
106
=head2 _init
116
107
117
=cut
108
=cut
118
109
Lines 132-151 sub _init { Link Here
132
    return Log::Log4perl->init_once($log4perl_config);
123
    return Log::Log4perl->init_once($log4perl_config);
133
}
124
}
134
125
135
sub _recheck_logfile {    # recheck saved logfile when logging message
136
    my $self = shift;
137
138
    return 1 if !exists $self->{logs};    # remember? your own responsibility
139
    my $opac = $self->{cat} =~ /^OPAC/;
140
    my $log;
141
    foreach ( @{ $self->{logs} } ) {
142
        $log = $_ if $opac && /^OPAC:/ || !$opac && /^INTRANET:/;
143
        last if $log;
144
    }
145
    $log =~ s/^(OPAC|INTRANET)://;
146
    return -w $log;
147
}
148
149
=head2 debug_to_screen
126
=head2 debug_to_screen
150
127
151
Adds a new appender for the given logger that will log all DEBUG-and-higher messages to stderr.
128
Adds a new appender for the given logger that will log all DEBUG-and-higher messages to stderr.
152
- 

Return to bug 25172