or die "Can't open $CONF->{_}->{logfile}: $!\n";
$LOGGER_FD->autoflush(1);
}
+ elsif ($CONFIG{debug}) {
+ $LOGGER_FD = \*STDERR;
+ }
}
my $DBH;
sub msg($@) {
my $name = shift;
return unless @_;
- logger($name, @_) if defined $LOGGER_FD and $LOGGER_FD ne \*STDERR;
+ logger($name, @_) if defined $LOGGER_FD and $LOGGER_FD->fileno != fileno STDERR;
my $prefix = defined $name ? "$name: " : '';
print STDERR $prefix, @_, "\n";
}
sub logger($@) {
my $name = shift;
return unless @_ and defined $LOGGER_FD;
- my $prefix = strftime "%b %e %H:%M:%S ", localtime;
+ my $prefix = '';
+ if ($LOGGER_FD->fileno != fileno STDERR) {
+ $prefix = strftime "%b %e %H:%M:%S ", localtime;
+ }
$prefix .= "$name: " if defined $name;
$LOGGER_FD->say($prefix, @_);
}
sub log($@) {
my $self = shift;
return unless @_;
- $self->logger(@_) if defined $self->{'logger-fd'} and $self->{'logger-fd'} ne \*STDERR;
+ $self->logger(@_) if defined $self->{'logger-fd'} and $self->{'logger-fd'}->fileno != fileno STDERR;
my $prefix = defined $self->{name} ? $self->{name} : '';
$prefix .= "($self->{_SELECTED})" if $self->{_STATE} eq 'SELECTED';
print STDERR $prefix, ': ', @_, "\n";
sub logger($@) {
my $self = shift;
return unless @_ and defined $self->{'logger-fd'};
- my $prefix = strftime "%b %e %H:%M:%S ", localtime;
+ my $prefix = '';
+ if ($self->{'logger-fd'}->fileno != fileno STDERR) {
+ $prefix = strftime "%b %e %H:%M:%S ", localtime;
+ }
$prefix .= defined "$self->{name}" ? $self->{name} : '';
$prefix .= "($self->{_SELECTED})" if $self->{_STATE} eq 'SELECTED';
$self->{'logger-fd'}->say($prefix, ': ', @_);