mirror of https://github.com/tstack/lnav.git
[session] support for :hide-file and some related fixes
This commit is contained in:
parent
13f161d21e
commit
0603b1e756
|
@ -3048,6 +3048,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
|
|||
}
|
||||
} catch (const line_buffer::error& e) {
|
||||
fprintf(stderr, "error: %s\n", strerror(e.e_err));
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr, "error: %s\n", e.what());
|
||||
}
|
||||
|
||||
// When reading from stdin, tell the user where the capture file is
|
||||
|
|
|
@ -403,6 +403,19 @@ rescan_files(bool req)
|
|||
delay = 30ms;
|
||||
}
|
||||
done = fc.fc_file_names.empty() && all_synced;
|
||||
if (!done && !(lnav_data.ld_flags & LNF_HEADLESS)) {
|
||||
lnav_data.ld_files_view.set_needs_update();
|
||||
lnav_data.ld_files_view.do_update();
|
||||
lnav_data.ld_top_source.update_time();
|
||||
lnav_data.ld_status[LNS_TOP].do_update();
|
||||
lnav_data.ld_status[LNS_BOTTOM].do_update();
|
||||
lnav_data.ld_rl_view->do_update();
|
||||
if (handle_winch()) {
|
||||
layout_views();
|
||||
lnav_data.ld_view_stack.do_update();
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
} while (!done && lnav_data.ld_looping);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2715,18 +2715,16 @@ com_file_visibility(exec_context& ec,
|
|||
|
||||
if (tss.empty()) {
|
||||
return ec.make_error("no text files are opened");
|
||||
} else {
|
||||
lf = tss.current_file();
|
||||
}
|
||||
lf = tss.current_file();
|
||||
} else if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
||||
if (tc->get_inner_height() == 0) {
|
||||
return ec.make_error("no log files loaded");
|
||||
} else {
|
||||
logfile_sub_source& lss = lnav_data.ld_log_source;
|
||||
vis_line_t vl = tc->get_top();
|
||||
content_line_t cl = lss.at(vl);
|
||||
lf = lss.find(cl);
|
||||
}
|
||||
auto& lss = lnav_data.ld_log_source;
|
||||
auto vl = tc->get_top();
|
||||
auto cl = lss.at(vl);
|
||||
lf = lss.find(cl);
|
||||
} else {
|
||||
return ec.make_error(
|
||||
":{} must be run in the log or text file views", args[0]);
|
||||
|
|
|
@ -112,13 +112,22 @@ namespace session {
|
|||
static nonstd::optional<ghc::filesystem::path>
|
||||
find_container_dir(ghc::filesystem::path file_path)
|
||||
{
|
||||
if (!ghc::filesystem::exists(file_path)) {
|
||||
return nonstd::nullopt;
|
||||
}
|
||||
|
||||
nonstd::optional<ghc::filesystem::path> dir_with_last_readme;
|
||||
|
||||
while (file_path.has_parent_path()) {
|
||||
while (file_path.has_parent_path()
|
||||
&& file_path != file_path.root_directory())
|
||||
{
|
||||
auto parent = file_path.parent_path();
|
||||
bool has_readme_entry = false;
|
||||
std::error_code ec;
|
||||
|
||||
for (const auto& entry : ghc::filesystem::directory_iterator(parent)) {
|
||||
for (const auto& entry :
|
||||
ghc::filesystem::directory_iterator(parent, ec))
|
||||
{
|
||||
if (!entry.is_regular_file()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -270,9 +279,11 @@ SELECT content_id, format, time_offset FROM lnav_file
|
|||
auto container_path_opt = find_container_dir(file_path);
|
||||
if (container_path_opt) {
|
||||
auto container_parent = container_path_opt.value().parent_path();
|
||||
auto file_container_path
|
||||
= ghc::filesystem::relative(file_path, container_parent)
|
||||
.string();
|
||||
file_containers[container_parent.string()].push_back(
|
||||
ghc::filesystem::relative(file_path, container_parent)
|
||||
.string());
|
||||
file_container_path);
|
||||
} else {
|
||||
raw_files.insert(file_path_str);
|
||||
}
|
||||
|
@ -431,6 +442,27 @@ SELECT content_id, format, time_offset FROM lnav_file
|
|||
sql_strftime(tsbuf, sizeof(tsbuf), max_time, 'T');
|
||||
fmt::print(file, FMT_STRING(":hide-lines-after {}\n"), tsbuf);
|
||||
}
|
||||
for (const auto& ld : *lss) {
|
||||
if (ld->is_visible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto container_path_opt
|
||||
= find_container_dir(ld->get_file_ptr()->get_path());
|
||||
if (!container_path_opt) {
|
||||
fmt::print(file,
|
||||
FMT_STRING(":hide-file {}\n"),
|
||||
ld->get_file_ptr()->get_path().string());
|
||||
continue;
|
||||
}
|
||||
auto container_parent
|
||||
= container_path_opt.value().parent_path();
|
||||
auto file_container_path = ghc::filesystem::relative(
|
||||
ld->get_file_ptr()->get_path(), container_parent);
|
||||
fmt::print(file,
|
||||
FMT_STRING(":hide-file */{}\n"),
|
||||
file_container_path.string());
|
||||
}
|
||||
}
|
||||
|
||||
if (!tc.get_current_search().empty()) {
|
||||
|
|
|
@ -955,6 +955,32 @@ tailer::looper::host_tailer::loop_body()
|
|||
log_error("symlink failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
if (pl.pl_root_path == pl.pl_path) {
|
||||
auto iter = conn.c_desired_paths.find(pl.pl_path);
|
||||
|
||||
if (iter != conn.c_desired_paths.end()) {
|
||||
if (iter->second.loo_tail) {
|
||||
conn.c_synced_desired_paths.insert(pl.pl_path);
|
||||
} else {
|
||||
log_info("synced desired path: %s",
|
||||
iter->first.c_str());
|
||||
conn.c_desired_paths.erase(iter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto iter = conn.c_child_paths.find(pl.pl_path);
|
||||
|
||||
if (iter != conn.c_child_paths.end()) {
|
||||
if (iter->second.loo_tail) {
|
||||
conn.c_synced_child_paths.insert(pl.pl_path);
|
||||
} else {
|
||||
log_info("synced child path: %s",
|
||||
iter->first.c_str());
|
||||
conn.c_child_paths.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::move(this->ht_state);
|
||||
},
|
||||
[&](const tailer::packet_preview_error& ppe) {
|
||||
|
|
|
@ -398,10 +398,10 @@ EXPECTED_FILES = \
|
|||
$(srcdir)/%reldir%/test_sessions.sh_4f13dd3858546b6e04a27e244159d355e368f2ae.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_68a89b56c5e7f7db620084cca1eb547cbb19a2c9.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_68a89b56c5e7f7db620084cca1eb547cbb19a2c9.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_6d87ff483d5785c58fb271a405ff1c35e4f83cd9.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_6d87ff483d5785c58fb271a405ff1c35e4f83cd9.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_858fd0081ed9c46dd81e2f81f1090756f2463558.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_858fd0081ed9c46dd81e2f81f1090756f2463558.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_8732dad5481be991ca7f291d9c5451c7b016cea7.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_8732dad5481be991ca7f291d9c5451c7b016cea7.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_903b41c950f5f90d7786d7a09bb6e2f217654b15.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_903b41c950f5f90d7786d7a09bb6e2f217654b15.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_92a98a3e4e3a10bf1f2371d21a8282c5d3d4baa5.err \
|
||||
|
@ -416,8 +416,6 @@ EXPECTED_FILES = \
|
|||
$(srcdir)/%reldir%/test_sessions.sh_b932b33dd087b94d4306dd179c5d4f9ddd394960.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_ddf45811e9906de9f3930fe802ac7b2cc6e48106.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_ddf45811e9906de9f3930fe802ac7b2cc6e48106.out \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_e39648f425c3f291c9d1c0d14595a019abd0cb48.err \
|
||||
$(srcdir)/%reldir%/test_sessions.sh_e39648f425c3f291c9d1c0d14595a019abd0cb48.out \
|
||||
$(srcdir)/%reldir%/test_shlexer.sh_14dd967cb2af90899c9e5e45d00b676b5a3163aa.err \
|
||||
$(srcdir)/%reldir%/test_shlexer.sh_14dd967cb2af90899c9e5e45d00b676b5a3163aa.out \
|
||||
$(srcdir)/%reldir%/test_shlexer.sh_2781f5dd570580cbe746ad91b58a28b8371283b3.err \
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#!lnav -Nf
|
||||
# This file is an export of an lnav session. You can type
|
||||
# '|/path/to/this/file' in lnav to execute this file and
|
||||
# restore the state of the session.
|
||||
|
||||
;SELECT raise_error('This session export was made with a newer version of lnav, please upgrade to ' || '0.11.0' || ' or later')
|
||||
WHERE lnav_version() < '0.11.0' COLLATE naturalcase
|
||||
|
||||
# The files loaded into the session were:
|
||||
|
||||
|
||||
;INSERT OR IGNORE INTO environ (name, value) VALUES ('LOG_DIR_0', '{test_dir}')
|
||||
:open $LOG_DIR_0/support-dump/logfile_access_log.0
|
||||
:open $LOG_DIR_0/support-dump/logfile_access_log.1
|
||||
|
||||
:rebuild
|
||||
|
||||
|
||||
# The following SQL statements will restore the bookmarks,
|
||||
# comments, and tags that were added in the session.
|
||||
|
||||
;SELECT total_changes() AS before_mark_changes
|
||||
;UPDATE all_logs SET log_mark = 1, log_comment = NULL, log_tags = NULL WHERE log_time_msecs = 1248130769000 AND log_format = 'access_log' AND log_line_hash = 'v1:b05c1bdfe75cde41e151c89087e31951'
|
||||
|
||||
;SELECT 1 - (total_changes() - $before_mark_changes) AS failed_mark_changes
|
||||
;SELECT echoln(printf('%sERROR%s: failed to restore %d bookmarks',
|
||||
$ansi_red, $ansi_norm, $failed_mark_changes))
|
||||
WHERE $failed_mark_changes != 0
|
||||
|
||||
|
||||
# The following commands will restore the state of the LOG view.
|
||||
|
||||
:switch-to-view log
|
||||
:hide-file */support-dump/logfile_access_log.1
|
||||
:goto 1
|
|
@ -29,12 +29,14 @@ run_cap_test ${lnav_test} -nq \
|
|||
mkdir -p support-dump
|
||||
echo 'Hello' > support-dump/readme
|
||||
cp ${test_dir}/logfile_access_log.0 support-dump/
|
||||
cp ${test_dir}/logfile_access_log.1 support-dump/
|
||||
|
||||
run_cap_test ${lnav_test} -nq \
|
||||
-c ";update access_log set log_mark = 1 where sc_bytes > 60000" \
|
||||
-c ":goto 1" \
|
||||
-c ":hide-file */logfile_access_log.1" \
|
||||
-c ":export-session-to -" \
|
||||
support-dump/logfile_access_log.0
|
||||
support-dump/logfile_access_log.*
|
||||
|
||||
run_cap_test ${lnav_test} -nq \
|
||||
-c ";update access_log set log_mark = 1 where sc_bytes > 60000" \
|
||||
|
|
Loading…
Reference in New Issue