diff --git a/AUTHORS b/AUTHORS index 1b7a92f8..a43716cb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,3 +27,4 @@ Justin Berger Jan Chren Geoff Crompton Medina Maza +Phil Hord diff --git a/NEWS b/NEWS index fec13dac..4fbcc546 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,15 @@ +lnav v0.8.4: + Features: + * Pressing left-arrow while viewing log messages will reveal the source + file name for each line. Pressing again will reveal the full path. + + Fixes: + * The HOME key should now work in the command-prompt and move the cursor + to the beginning of the line. + * The :delete-filter command should now tab-complete existing filters. + * Milliseconds can now be used in relative times (e.g. 10:00:00.123) + lnav v0.8.3: Features: * Support for the Bro Network Security Monitor (https://www.bro.org) log diff --git a/docs/source/hotkeys.rst b/docs/source/hotkeys.rst index a227e8d5..7b51afb2 100644 --- a/docs/source/hotkeys.rst +++ b/docs/source/hotkeys.rst @@ -70,7 +70,9 @@ Spatial Navigation * - |ks| h |ke| - |ks| ← |ke| - - - Left half a page + - Left half a page. In the log view, pressing left while at the start of + the message text will reveal the source file name for each line. + Pressing again will reveal the full path. * - |ks| Shift |ke| + |ks| h |ke| - |ks| Shift |ke| + |ks| ← |ke| - @@ -209,8 +211,6 @@ Display log_line column * - |ks| p |ke| - Toggle the display of the log parser results - * - |ks| . |ke| - - Toggle the display of the log file names * - |ks| Tab |ke| - Cycle through colums to graph in the SQL result view * - |ks| Ctrl |ke| + |ks| l |ke| diff --git a/src/help.txt b/src/help.txt index 903f3664..0bbdcc5c 100644 --- a/src/help.txt +++ b/src/help.txt @@ -119,8 +119,10 @@ the file where warnings or errors are detected by coloring the bar yellow or red, respectively. Tick marks will also be added to the left and right hand side of the bar, for search hits and bookmarks. -When multiple files are open, a bar on the left side is color coded and -broken up to indicate which messages are from the same file. +A bar on the left side is color coded and broken up to indicate which +messages are from the same file. Pressing the left-arrow or 'h' will +reveal the source file names for each message and pressing again will +show the full paths. When at the bottom of the log view, a summary line will be displayed on the right-hand-side to give you some more information about your logs, including: @@ -190,7 +192,9 @@ Spatial Navigation b/bs/pgup Move up a page. j/cr/down-arrow Move down a line. k/up-arrow Move up a line. - h/left-arrow Move to the left. + h/left-arrow Move to the left. In the log view, moving left will reveal + the source log file names for each line. Pressing again + will reveal the full path. l/right-arrow Move to the right. H/Shift+left Move to the left by a smaller increment. L/Shift+right Move to the right by a smaller increment. @@ -295,9 +299,6 @@ Display options means it has sped up. You can use the "s/S" hotkeys to scan through the slow downs. - . In the log view, toggle the display of filenames showing - where each log line comes from. - i View/leave a histogram of the log messages over time. The histogram counts the number of displayed log lines for each bucket of time. The diff --git a/src/hotkeys.cc b/src/hotkeys.cc index b6e29681..a5eb93d7 100644 --- a/src/hotkeys.cc +++ b/src/hotkeys.cc @@ -985,11 +985,6 @@ void handle_paging_key(int ch) tc->reload_data(); break; - case '.': - lnav_data.ld_log_source.toggle_filename(); - tc->reload_data(); - break; - case 'i': if (toggle_view(&lnav_data.ld_views[LNV_HISTOGRAM])) { lnav_data.ld_rl_view->set_alt_value( diff --git a/src/lnav.cc b/src/lnav.cc index f47f73a3..567d3409 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -1836,6 +1836,33 @@ static void handle_key(int ch) { if (lnav_data.ld_mode == LNM_PAGING) { if (!lnav_data.ld_view_stack.empty()) { textview_curses *tc = lnav_data.ld_view_stack.back(); + logfile_sub_source *lss = NULL; + + lss = dynamic_cast(tc->get_sub_source()); + + if (lss != nullptr) { + switch (ch) { + case 'h': + case 'H': + case KEY_SLEFT: + case KEY_LEFT: + if (tc->get_left() == 0) { + lss->increase_line_context(); + tc->set_needs_update(); + return; + } + break; + case 'l': + case 'L': + case KEY_SRIGHT: + case KEY_RIGHT: + if (lss->decrease_line_context()) { + tc->set_needs_update(); + return; + } + break; + } + } if (tc->handle_key(ch)) { return; diff --git a/src/logfile_sub_source.hh b/src/logfile_sub_source.hh index 33ddb9c4..9ff8b606 100644 --- a/src/logfile_sub_source.hh +++ b/src/logfile_sub_source.hh @@ -97,19 +97,38 @@ public: this->clear_line_size_cache(); }; - void toggle_filename(void) { - // NONE -> F_BASENAME -> F_FILENAME -> NONE ... - if (this->lss_flags & F_BASENAME) { - // F_BASENAME -> F_FILENAME - this->lss_flags ^= F_BASENAME | F_FILENAME; - } else if (this->lss_flags & F_FILENAME) { - // F_FILENAME -> NONE - this->lss_flags ^= F_FILENAME; + void increase_line_context(void) { + long old_flags = this->lss_flags; + + if (this->lss_flags & F_FILENAME) { + // Nothing to do + } else if (this->lss_flags & F_BASENAME) { + this->lss_flags &= ~F_NAME_MASK; + this->lss_flags |= F_FILENAME; } else { - // NONE -> F_BASENAME - this->lss_flags ^= F_BASENAME; + this->lss_flags |= F_BASENAME; } - this->clear_line_size_cache(); + if (old_flags != this->lss_flags) { + this->clear_line_size_cache(); + } + }; + + bool decrease_line_context(void) { + long old_flags = this->lss_flags; + + if (this->lss_flags & F_FILENAME) { + this->lss_flags &= ~F_NAME_MASK; + this->lss_flags |= F_BASENAME; + } else if (this->lss_flags & F_BASENAME) { + this->lss_flags &= ~F_NAME_MASK; + } + if (old_flags != this->lss_flags) { + this->clear_line_size_cache(); + + return true; + } + + return false; }; void set_time_offset(bool enabled) { @@ -523,6 +542,8 @@ private: F_TIME_OFFSET = (1L << B_TIME_OFFSET), F_FILENAME = (1L << B_FILENAME), F_BASENAME = (1L << B_BASENAME), + + F_NAME_MASK = (F_FILENAME | F_BASENAME), }; struct __attribute__((__packed__)) indexed_content { diff --git a/test/expected_help.txt b/test/expected_help.txt index 97a3a45a..0f6c84e6 100644 --- a/test/expected_help.txt +++ b/test/expected_help.txt @@ -119,8 +119,10 @@ the file where warnings or errors are detected by coloring the bar yellow or red, respectively. Tick marks will also be added to the left and right hand side of the bar, for search hits and bookmarks. -When multiple files are open, a bar on the left side is color coded and -broken up to indicate which messages are from the same file. +A bar on the left side is color coded and broken up to indicate which +messages are from the same file. Pressing the left-arrow or 'h' will +reveal the source file names for each message and pressing again will +show the full paths. When at the bottom of the log view, a summary line will be displayed on the right-hand-side to give you some more information about your logs, including: @@ -190,7 +192,9 @@ Spatial Navigation b/bs/pgup Move up a page. j/cr/down-arrow Move down a line. k/up-arrow Move up a line. - h/left-arrow Move to the left. + h/left-arrow Move to the left. In the log view, moving left will reveal + the source log file names for each line. Pressing again + will reveal the full path. l/right-arrow Move to the right. H/Shift+left Move to the left by a smaller increment. L/Shift+right Move to the right by a smaller increment. @@ -295,9 +299,6 @@ Display options means it has sped up. You can use the "s/S" hotkeys to scan through the slow downs. - . In the log view, toggle the display of filenames showing - where each log line comes from. - i View/leave a histogram of the log messages over time. The histogram counts the number of displayed log lines for each bucket of time. The