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 133-152 sub _init { Link Here
133
    return Log::Log4perl->init_once($log4perl_config);
124
    return Log::Log4perl->init_once($log4perl_config);
134
}
125
}
135
126
136
sub _recheck_logfile {    # recheck saved logfile when logging message
137
    my $self = shift;
138
139
    return 1 if !exists $self->{logs};    # remember? your own responsibility
140
    my $opac = $self->{cat} =~ /^OPAC/;
141
    my $log;
142
    foreach ( @{ $self->{logs} } ) {
143
        $log = $_ if $opac && /^OPAC:/ || !$opac && /^INTRANET:/;
144
        last if $log;
145
    }
146
    $log =~ s/^(OPAC|INTRANET)://;
147
    return -w $log;
148
}
149
150
=head2 debug_to_screen
127
=head2 debug_to_screen
151
128
152
Adds a new appender for the given logger that will log all DEBUG-and-higher messages to stderr.
129
Adds a new appender for the given logger that will log all DEBUG-and-higher messages to stderr.
153
- 

Return to bug 25172