Skip to content

Commit

Permalink
[files] add a comment about log format match
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Jun 19, 2024
1 parent 6538675 commit 11545f8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/base/itertools.hh
Original file line number Diff line number Diff line change
Expand Up @@ -602,14 +602,26 @@ template<typename T,
typename F,
std::enable_if_t<lnav::func::is_invocable<F, T>::value, int> = 0>
void
operator|(std::vector<std::shared_ptr<T>>& in,
operator|(const std::vector<std::shared_ptr<T>>& in,
const lnav::itertools::details::for_eacher<F>& eacher)
{
for (auto& elem : in) {
lnav::func::invoke(eacher.fe_func, *elem);
}
}

template<typename T,
typename F,
std::enable_if_t<lnav::func::is_invocable<F, T>::value, int> = 0>
void
operator|(const std::vector<T>& in,
const lnav::itertools::details::for_eacher<F>& eacher)
{
for (auto& elem : in) {
lnav::func::invoke(eacher.fe_func, elem);
}
}

template<typename T,
typename F,
std::enable_if_t<lnav::func::is_invocable<F, T>::value, int> = 0>
Expand Down
20 changes: 19 additions & 1 deletion src/files_sub_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,26 @@ files_sub_source::text_selection_changed(textview_curses& tc)
}
details.emplace_back(line);
}
auto match_msgs = lf->get_format_match_messages();

if (lf->get_format_ptr() != nullptr) {
const auto um = lnav::console::user_message::info(
attr_line_t("The file contents matched this log format and "
"will be shown in the LOG view"));
um.to_attr_line().rtrim().split_lines()
| lnav::itertools::for_each([&details](const auto& al) {
details.emplace_back(attr_line_t(" ").append(al));
});
} else {
const auto um = lnav::console::user_message::info(attr_line_t(
"The file contents did not match any log "
"formats and can be accessed in the TEXT view"));
um.to_attr_line().rtrim().split_lines()
| lnav::itertools::for_each([&details](const auto& al) {
details.emplace_back(attr_line_t(" ").append(al));
});
}

const auto& match_msgs = lf->get_format_match_messages();
details.emplace_back(
attr_line_t(" ").append("Match Details"_h3));
for (const auto& msg : match_msgs) {
Expand Down

0 comments on commit 11545f8

Please sign in to comment.