1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 21:07:39 +03:00

[cmds] reduce next/prev mark errors to info to make them less noisy

This commit is contained in:
Tim Stack 2022-08-29 02:54:31 -07:00
parent e90fe620c9
commit cebc867c6b
5 changed files with 51 additions and 13 deletions

View File

@ -7,11 +7,12 @@ RUN set -eux; \
apt install --yes --no-install-recommends bind9-dnsutils iputils-ping iproute2 curl ca-certificates htop wget unzip openssh-server; \ apt install --yes --no-install-recommends bind9-dnsutils iputils-ping iproute2 curl ca-certificates htop wget unzip openssh-server; \
apt clean autoclean; \ apt clean autoclean; \
apt autoremove --yes; \ apt autoremove --yes; \
wget https://github.com/tstack/lnav/releases/download/v0.11.0-beta2/lnav-0.11.0-musl-64bit.zip; \
unzip lnav-0.11.0-musl-64bit.zip; \
rm -rf /var/lib/{apt,dpkg,cache,log}/; \ rm -rf /var/lib/{apt,dpkg,cache,log}/; \
echo "Installed base utils!" echo "Installed base utils!"
ADD https://github.com/tstack/lnav/releases/download/v0.11.0-beta2/lnav-0.11.0-musl-64bit.zip /
RUN unzip lnav-0.11.0-musl-64bit.zip
COPY docs/tutorials tutorials COPY docs/tutorials tutorials
RUN useradd -rm -d /home/logs -s /bin/bash logs RUN useradd -rm -d /home/logs -s /bin/bash logs
@ -22,14 +23,20 @@ RUN useradd -rm -d /home/tutorial1 -s /bin/bash tutorial1
RUN echo 'tutorial1:tutorial1' | chpasswd RUN echo 'tutorial1:tutorial1' | chpasswd
RUN passwd -d tutorial1 RUN passwd -d tutorial1
RUN useradd -rm -d /home/debug -s /bin/bash debug
RUN echo 'debug:debug' | chpasswd
USER tutorial1 USER tutorial1
RUN /lnav-0.11.0/lnav -nN -c ":config /ui/theme monocai" RUN /lnav-0.11.0/lnav -nN -c ":config /ui/theme monocai"
USER root USER root
RUN echo 'ForceCommand env LNAVSECURE=1 TERM=xterm-256color /lnav-0.11.0/lnav -c ":switch-to-view text" -I /tutorials/tutorial-lib /tutorials/tutorial1/tutorial1.glog /tutorials/tutorial1/index.md#tutorial-1' >> /etc/ssh/sshd_config RUN echo 'Match User logs' >> /etc/ssh/sshd_config
RUN echo 'ForceCommand env LNAVSECURE=1 TERM=xterm-256color /lnav-0.11.0/lnav -d /tmp/lnav.err /demo' >> /etc/ssh/sshd_config
RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config
RUN echo 'Match User tutorial1' >> /etc/ssh/sshd_config
RUN echo 'ForceCommand env PATH=/lnav-0.11.0:$PATH /tutorials/tutorial1/run.sh' >> /etc/ssh/sshd_config
RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config
RUN cat /etc/ssh/sshd_config
RUN service ssh start RUN service ssh start
EXPOSE 22 EXPOSE 22

View File

@ -0,0 +1,6 @@
#!/bin/bash
export LNAVSECURE=1
export TERM=xterm-256color
lnav -I /tutorials/tutorial-lib /tutorials/tutorial1/tutorial1.glog /tutorials/tutorial1/index.md#tutorial-1

View File

@ -1106,6 +1106,15 @@ exec_context::execute(const std::string& cmdline)
void void
exec_context::add_error_context(lnav::console::user_message& um) exec_context::add_error_context(lnav::console::user_message& um)
{ {
switch (um.um_level) {
case lnav::console::user_message::level::raw:
case lnav::console::user_message::level::info:
case lnav::console::user_message::level::ok:
return;
default:
break;
}
if (um.um_snippets.empty()) { if (um.um_snippets.empty()) {
um.with_snippets(this->ec_source); um.with_snippets(this->ec_source);
} }

View File

@ -1194,11 +1194,18 @@ looper()
auto ecb_guard auto ecb_guard
= lnav_data.ld_exec_context.add_error_callback([](const auto& um) { = lnav_data.ld_exec_context.add_error_callback([](const auto& um) {
lnav_data.ld_user_message_source.replace_with( auto al = um.to_attr_line().rtrim();
um.to_attr_line().rtrim());
lnav_data.ld_user_message_view.reload_data(); if (al.get_string().find('\n') == std::string::npos) {
lnav_data.ld_user_message_expiration if (lnav_data.ld_rl_view) {
= std::chrono::steady_clock::now() + 20s; lnav_data.ld_rl_view->set_attr_value(al);
}
} else {
lnav_data.ld_user_message_source.replace_with(al);
lnav_data.ld_user_message_view.reload_data();
lnav_data.ld_user_message_expiration
= std::chrono::steady_clock::now() + 20s;
}
}); });
{ {

View File

@ -715,12 +715,14 @@ com_goto_mark(exec_context& ec,
} }
if (!new_top) { if (!new_top) {
return ec.make_error( auto um = lnav::console::user_message::info(fmt::format(
"no more {} bookmarks after here", FMT_STRING("no more {} bookmarks after here"),
fmt::join(mark_types fmt::join(mark_types
| lnav::itertools::map( | lnav::itertools::map(
&bookmark_type_t::get_name), &bookmark_type_t::get_name),
", ")); ", ")));
return Err(um);
} }
} else { } else {
for (const auto& bt : mark_types) { for (const auto& bt : mark_types) {
@ -733,7 +735,14 @@ com_goto_mark(exec_context& ec,
} }
if (!new_top) { if (!new_top) {
return ec.make_error("no more bookmarks before here"); auto um = lnav::console::user_message::info(fmt::format(
FMT_STRING("no more {} bookmarks before here"),
fmt::join(mark_types
| lnav::itertools::map(
&bookmark_type_t::get_name),
", ")));
return Err(um);
} }
} }