From ce18b29d175ef5f01f05d59c95bcf8e0cd40e611 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 19 Apr 2019 07:41:22 +0000 Subject: index: warn with info about the message as context This can help users track down the source of warnings when presented with imperfect emails. While we're at it, make the __WARN__ callback in t/v2writable.t a no-op since we don't check for warnings, there. --- lib/PublicInbox/SearchIdxPart.pm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/PublicInbox/SearchIdxPart.pm') diff --git a/lib/PublicInbox/SearchIdxPart.pm b/lib/PublicInbox/SearchIdxPart.pm index 7fe2120a..51d81a0a 100644 --- a/lib/PublicInbox/SearchIdxPart.pm +++ b/lib/PublicInbox/SearchIdxPart.pm @@ -48,8 +48,15 @@ sub spawn_worker { sub partition_worker_loop ($$$$) { my ($self, $r, $part, $bnote) = @_; $0 = "pi-v2-partition[$part]"; + my $current_info = ''; + my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ }; + local $SIG{__WARN__} = sub { + chomp $current_info; + $warn_cb->("[$part] $current_info: ", @_); + }; $self->begin_txn_lazy; while (my $line = $r->getline) { + $current_info = $line; if ($line eq "commit\n") { $self->commit_txn_lazy; } elsif ($line eq "close\n") { -- cgit v1.2.3-24-ge0c7