diff options
author | Eric Wong <e@yhbt.net> | 2020-08-27 12:16:59 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-08-27 22:33:41 +0000 |
commit | 43b66634d508a1cd81023b5d567abae3804420c4 (patch) | |
tree | 725aec1b5b4c4d89ea5e4e9db6fe70f11b258d55 | |
parent | b80dccff433cc529040e3c11604d76f669570511 (diff) | |
download | public-inbox-43b66634d508a1cd81023b5d567abae3804420c4.tar.gz |
For consistency in output, any URL/path-context-dependent prefixes should have the same prefix as the actual warning which triggered it.
-rw-r--r-- | lib/PublicInbox/WatchMaildir.pm | 11 |
1 files changed, 8 insertions, 3 deletions
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; |