aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2015-07-31 22:40:28 +0200
committerGuilhem Moulin <guilhem@fripost.org>2015-07-31 22:40:30 +0200
commit69502140d2e229a314bb1eb192d31b9a2c14f981 (patch)
tree75ba8c76a9f2c1d130107e404da5530f79004850 /lib
parent74ef024258870c9f767688f9305c1fab3e4ce393 (diff)
Log debug messages to STDERR unless 'logfile' is set.
However don't include timestamps to STDERR, that's the job of the syslog.
Diffstat (limited to 'lib')
-rw-r--r--lib/Net/IMAP/Sync.pm7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Net/IMAP/Sync.pm b/lib/Net/IMAP/Sync.pm
index 47c6258..b44f0a6 100644
--- a/lib/Net/IMAP/Sync.pm
+++ b/lib/Net/IMAP/Sync.pm
@@ -392,7 +392,7 @@ sub DESTROY($) {
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";
@@ -400,7 +400,10 @@ sub log($@) {
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, ': ', @_);