From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 5/5] lei up --all: show output for warnings
Date: Tue, 12 Oct 2021 22:45:00 +0000 [thread overview]
Message-ID: <20211012224500.2882-6-e@80x24.org> (raw)
In-Reply-To: <20211012224500.2882-1-e@80x24.org>
This helps users make sense of which saved searches some
warnings were coming from.
Since I often create and discard externals, some warnings
from saved searches were confusing to me without output context:
"`$FOO' is unknown"
"$FOO not indexed by Xapian"
---
lib/PublicInbox/LEI.pm | 12 ++++++++----
lib/PublicInbox/LeiUp.pm | 7 +++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 51b0e95e1728..183cb545fe55 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -522,7 +522,7 @@ sub sigint_reap {
sub fail ($$;$) {
my ($self, $buf, $exit_code) = @_;
$self->{failed}++;
- err($self, $buf) if defined $buf;
+ warn($buf, "\n") if defined $buf;
$self->{pkt_op_p}->pkt_do('fail_handler') if $self->{pkt_op_p};
x_it($self, ($exit_code // 1) << 8);
undef;
@@ -542,7 +542,7 @@ sub puts ($;@) { out(shift, map { "$_\n" } @_) }
sub child_error { # passes non-fatal curl exit codes to user
my ($self, $child_error, $msg) = @_; # child_error is $?
$child_error ||= 1 << 8;
- $self->err($msg) if $msg;
+ warn($msg, "\n") if defined $msg;
if ($self->{pkt_op_p}) { # to top lei-daemon
$self->{pkt_op_p}->pkt_do('child_error', $child_error);
} elsif ($self->{sock}) { # to lei(1) client
@@ -588,8 +588,12 @@ sub _lei_atfork_child {
eval 'no warnings; undef $PublicInbox::LeiNoteEvent::to_flush';
undef $errors_log;
$quit = \&CORE::exit;
- $self->{-eml_noisy} or # only "lei import" sets this atm
- $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb();
+ if (!$self->{-eml_noisy}) { # only "lei import" sets this atm
+ my $cb = $SIG{__WARN__} // \&CORE::warn;
+ $SIG{__WARN__} = sub {
+ $cb->(@_) unless PublicInbox::Eml::warn_ignore(@_)
+ };
+ }
$current_lei = $persist ? undef : $self; # for SIG{__WARN__}
}
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index 3e1ca21e29e7..3011300dd836 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -159,6 +159,13 @@ sub event_step { # runs via PublicInbox::DS::requeue
delete $l->{opt}->{all};
$l->qerr("# updating $self->{out}");
$l->{up_op_p} = $self->{op_p}; # ($l => $lei => script/lei)
+ my $cb = $SIG{__WARN__} // \&CORE::warn;
+ my $o = " (output: $self->{out})";
+ local $SIG{__WARN__} = sub {
+ my @m = @_;
+ push(@m, $o) if !@m || $m[-1] !~ s/\n\z/$o\n/;
+ $cb->(@m);
+ };
eval { $l->dispatch('up', $self->{out}) };
$lei->child_error(0, $@) if $@ || $l->{failed}; # lei->fail()
prev parent reply other threads:[~2021-10-12 22:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 22:44 [PATCH 0/5] fix extindex reindex harder Eric Wong
2021-10-12 22:44 ` [PATCH 1/5] extindex: flush pending reindex before unref Eric Wong
2021-10-12 22:44 ` [PATCH 2/5] lei/store: use remove_doc to save some LoC Eric Wong
2021-10-12 22:44 ` [PATCH 3/5] index: optimize after all SQLite DB commits Eric Wong
2021-10-12 22:44 ` [PATCH 4/5] doc: relnotes: note some recent improvements Eric Wong
2021-10-12 22:45 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211012224500.2882-6-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).