From 43b66634d508a1cd81023b5d567abae3804420c4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 27 Aug 2020 12:16:59 +0000 Subject: watchmaildir: ensure I:/W:/E: prefixes in warnings For consistency in output, any URL/path-context-dependent prefixes should have the same prefix as the actual warning which triggered it. --- lib/PublicInbox/WatchMaildir.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/WatchMaildir.pm') diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm index 2ba10a9e..768e0efe 100644 --- a/lib/PublicInbox/WatchMaildir.pm +++ b/lib/PublicInbox/WatchMaildir.pm @@ -198,7 +198,10 @@ sub _try_path { return; } my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ }; - local $SIG{__WARN__} = sub { $warn_cb->("path: $path\n", @_) }; + local $SIG{__WARN__} = sub { + my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : ''; + $warn_cb->($pfx, "path: $path\n", @_); + }; if (!ref($inboxes) && $inboxes eq 'watchspam') { return _remove_spam($self, $path); } @@ -443,8 +446,9 @@ sub imap_fetch_all ($$$) { my ($uids, $batch); my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ }; local $SIG{__WARN__} = sub { + my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : ''; $batch //= '?'; - $warn_cb->("$url UID:$batch\n", @_); + $warn_cb->("$pfx$url UID:$batch\n", @_); }; my $err; do { @@ -875,7 +879,8 @@ sub nntp_fetch_all ($$$) { my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ }; my ($err, $art); local $SIG{__WARN__} = sub { - $warn_cb->("$url ", $art ? ("ARTICLE $art") : (), "\n", @_); + my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : ''; + $warn_cb->("$pfx$url ", $art ? ("ARTICLE $art") : (), "\n", @_); }; my $inboxes = $self->{nntp}->{$url}; my $last_art; -- cgit v1.2.3-24-ge0c7