From: Marius Gavrilescu <marius@ieval.ro>
Date: Sat, 7 Jan 2017 18:50:29 +0000 (+0200)
Subject: Write debug messages on STDERR
X-Git-Tag: 0.002~2
X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=45e63402a29d03e13babf2d8937b98047df14bfc;p=app-lastmsg.git

Write debug messages on STDERR
---

diff --git a/lastmsg b/lastmsg
index 65b4786..ee7e68a 100755
--- a/lastmsg
+++ b/lastmsg
@@ -103,8 +103,8 @@ F</usr/local/etc/>. See L<Config::Auto> for more information.
 =head1 ENVIRONMENT
 
 The only recognised environment variable is B<LASTMSG_DEBUG>, which if
-set to a true value causes the script to emit a lot of information
-about what it is doing.
+set to a true value causes the script to emit a lot of information on
+STDERR about what it is doing.
 
 =head1 TODO
 
diff --git a/lib/App/Lastmsg.pm b/lib/App/Lastmsg.pm
index 8d2cce5..07f71db 100644
--- a/lib/App/Lastmsg.pm
+++ b/lib/App/Lastmsg.pm
@@ -59,14 +59,14 @@ sub run {
 
 	for my $folder (@{$config->{inbox}}) {
 		next unless -e $folder;
-		say "Scanning $folder (inbox)" if $ENV{LASTMSG_DEBUG};
+		say STDERR "Scanning $folder (inbox)" if $ENV{LASTMSG_DEBUG};
 		my $folder = Email::Folder->new($folder);
 		while (my $msg = $folder->next_message) {
 			my ($from) = grep { /^from$/i } $msg->header_names;
 			$from = $msg->header_raw($from);
 			if ($ENV{LASTMSG_DEBUG}) {
 				my $mid = grep { /^message-id$/i } $msg->header_names;
-				say 'Processing ', $msg->header_raw('Message-ID'),
+				say STDERR 'Processing ', $msg->header_raw('Message-ID'),
 				  " from $from" if $ENV{LASTMSG_DEBUG};
 			}
 			$process_message->($msg, $from);
@@ -75,7 +75,7 @@ sub run {
 
 	for my $folder (@{$config->{sent}}) {
 		next unless -e $folder;
-		say "Scanning $folder (sent)" if $ENV{LASTMSG_DEBUG};
+		say STDERR "Scanning $folder (sent)" if $ENV{LASTMSG_DEBUG};
 		my $folder = Email::Folder->new($folder);
 		while (my $msg = $folder->next_message) {
 			my @hdrs = grep { /^(?:to|cc|bcc)$/i } $msg->header_names;
@@ -85,7 +85,7 @@ sub run {
 			}
 			if ($ENV{LASTMSG_DEBUG}) {
 				my $mid = grep { /^message-id$/i } $msg->header_names;
-				say 'Processing ', $msg->header_raw($mid),
+				say STDERR 'Processing ', $msg->header_raw($mid),
 				  ' sent to ', join ',', @people if $ENV{LASTMSG_DEBUG};
 			}
 			$process_message->($msg, @people);