Skip to content

Commit 0a85d60

Browse files
committed
Merge branch 'master' into develop
2 parents 30278b5 + ec92ef1 commit 0a85d60

58 files changed

Lines changed: 1721 additions & 1087 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ Features:
5454
## lnav v0.14.1
5555

5656
Features:
57+
* The DB view now shows a status bar above the bottom
58+
status bar with the SQL query that populated the view,
59+
the relative time when it was run, and how long it took.
60+
A reload icon at the left side of the bar can be clicked
61+
to re-run the query. For queries that read from log-backed
62+
tables, the status bar also calls out whether the results
63+
are "on current log data" or "on old log data" relative to
64+
what lnav is currently indexing. The same information is
65+
exposed via the new `lnav_views.view_details` column.
5766
* For terminals that support the Kitty Keyboard
5867
protocol, the following hotkeys are now supported
5968
in the prompt:

TESTS_ENVIRONMENT.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ run_cap_test() {
122122

123123
sed -ibak \
124124
-e "s;${prefix}/etc;{prefix}/etc;g" \
125+
-e 's;run_at\\":\\".*\\";;' \
125126
-e "s;${LNAV_VERSION};{LNAV_VERSION};g" \
126127
-e "s;${test_dir};{test_dir};g" \
127128
-e "s;${builddir};{test_dir};g" \

docs/schemas/config-v1.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@
557557
"description": "Icon for a 'busy' status",
558558
"title": "/ui/theme-defs/<theme_name>/icons/busy",
559559
"$ref": "#/definitions/icon"
560+
},
561+
"reload": {
562+
"description": "Icon for a 'reload' button",
563+
"title": "/ui/theme-defs/<theme_name>/icons/reload",
564+
"$ref": "#/definitions/icon"
560565
}
561566
},
562567
"additionalProperties": false
@@ -646,6 +651,11 @@
646651
"title": "/ui/theme-defs/<theme_name>/styles/offset-time",
647652
"$ref": "#/definitions/style"
648653
},
654+
"time-ago": {
655+
"description": "Styling for a relative 'N ago' timestamp",
656+
"title": "/ui/theme-defs/<theme_name>/styles/time-ago",
657+
"$ref": "#/definitions/style"
658+
},
649659
"time-column": {
650660
"description": "Styling for the time column",
651661
"title": "/ui/theme-defs/<theme_name>/styles/time-column",

docs/source/ui.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,21 @@ PRQL [#]_ statement.
429429

430430
Press :kbd:`v` to switch to the database result view.
431431

432+
A status bar above the bottom status bar shows the query that populated
433+
the view, how long ago it ran, and how long it took. Clicking
434+
the reload icon (↻) at the left of the bar re-runs the query.
435+
436+
If the query reads from log-backed tables (:code:`all_logs`,
437+
per-format tables like :code:`syslog_log`, :code:`all_opids`, etc.),
438+
the timing status also notes whether the results are based on
439+
the current log data or old log data. For queries that don't
440+
read from log data (e.g. :code:`;SELECT 1`), the timing status
441+
does not mention the log data freshness.
442+
443+
The same query metadata is exposed via the :code:`view_details`
444+
column on the :code:`lnav_views` vtable as a JSON object containing
445+
:code:`query`, :code:`run_at`, and :code:`duration_us`.
446+
432447
.. [#] lnav must be compiled in an environment with Rust/Cargo available
433448
for PRQL support.
434449

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ add_library(
536536
command_executor.cc
537537
crashd.client.cc
538538
curl_looper.cc
539+
db_status_source.cc
539540
db_sub_source.cc
540541
dump_internals.cc
541542
elem_to_json.cc
@@ -674,6 +675,7 @@ add_library(
674675
column_namer.hh
675676
crashd.client.hh
676677
curl_looper.hh
678+
db_status_source.hh
677679
doc_status_source.hh
678680
dump_internals.hh
679681
elem_to_json.hh

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ noinst_HEADERS = \
274274
data_scanner.hh \
275275
data_scanner_re.re \
276276
data_parser.hh \
277+
db_status_source.hh \
277278
db_sub_source.hh \
278279
doc_status_source.hh \
279280
document.sections.hh \
@@ -501,6 +502,7 @@ libdiag_a_SOURCES = \
501502
command_executor.cc \
502503
crashd.client.cc \
503504
curl_looper.cc \
505+
db_status_source.cc \
504506
db_sub_source.cc \
505507
document.sections.cc \
506508
dump_internals.cc \

src/base/humanize.time.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,14 @@ point::as_time_ago() const
6969
if (delta < 0s) {
7070
return "in the future";
7171
}
72-
if (delta < 1min) {
72+
if (delta < 5s) {
7373
return "just now";
7474
}
75+
if (delta < 1min) {
76+
return fmt::format(
77+
FMT_STRING("{}s ago"),
78+
std::chrono::duration_cast<std::chrono::seconds>(delta).count());
79+
}
7580
if (delta < 2min) {
7681
return "one minute ago";
7782
}

src/base/humanize.time.tests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ TEST_CASE("time ago")
4242
auto t1_chrono = std::chrono::seconds(t1);
4343

4444
auto p1 = humanize::time::point::from_tv({t1, 0}).with_recent_point(
45-
{(time_t) t1 + 5, 0});
45+
{(time_t) t1 + 4, 0});
4646

4747
CHECK(p1.as_time_ago() == "just now");
48-
CHECK(p1.as_precise_time_ago() == " 5 seconds ago");
48+
CHECK(p1.as_precise_time_ago() == " 4 seconds ago");
4949

5050
auto p2 = humanize::time::point::from_tv({t1, 0}).with_recent_point(
5151
{(time_t) t1 + 65, 0});

src/base/lnav.console.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,8 @@ wchar_for_icon(ui_icon_t ic)
541541
return {U'\u2291', role_t::VCR_TEXT};
542542
case ui_icon_t::busy:
543543
return {U'\u23f3', role_t::VCR_TEXT};
544+
case ui_icon_t::reload:
545+
return {U'\u21bb', role_t::VCR_WARNING};
544546
}
545547

546548
ensure(false);

src/base/string_attr_type.hh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ enum class ui_icon_t : int32_t {
7575
tag,
7676
partition,
7777
busy,
78+
reload,
7879
};
7980

80-
constexpr auto ui_icon_count = lnav::enums::to_underlying(ui_icon_t::busy) + 1;
81+
constexpr auto ui_icon_count
82+
= lnav::enums::to_underlying(ui_icon_t::reload) + 1;
8183

8284
/** Roles that can be mapped to curses attributes using attrs_for_role() */
8385
enum class role_t : int32_t {
@@ -98,6 +100,7 @@ enum class role_t : int32_t {
98100
VCR_ADJUSTED_TIME,
99101
VCR_SKEWED_TIME,
100102
VCR_OFFSET_TIME,
103+
VCR_TIME_AGO,
101104
VCR_TIME_COLUMN,
102105
VCR_TIME_COLUMN_TO_TEXT,
103106
VCR_FILE_OFFSET,
@@ -537,6 +540,13 @@ ok(S str)
537540
return std::make_pair(std::move(str), VC_ROLE.value(role_t::VCR_OK));
538541
}
539542

543+
template<typename S>
544+
std::pair<S, string_attr_pair>
545+
time_ago(S str)
546+
{
547+
return std::make_pair(std::move(str), VC_ROLE.value(role_t::VCR_TIME_AGO));
548+
}
549+
540550
template<typename S>
541551
std::pair<S, string_attr_pair>
542552
hidden(S str)

0 commit comments

Comments
 (0)