[docs] mention the view tables

Defect Number:
    Reviewed By:
   Testing Done:
pull/757/head
Timothy Stack 4 years ago
parent d5373abeb4
commit 0744a9b6de

@ -5,10 +5,15 @@ SQLite Tables Reference
=======================
In addition to the tables generated for each log format, **lnav** includes
the following tables:
the following tables/views:
* environ
* lnav_file
* lnav_views
* lnav_view_stack
* lnav_view_filters
* lnav_view_filter_stats
* lnav_view_filters_and_stats
* all_logs
* http_status_codes
@ -40,6 +45,22 @@ named "FILENAME" and then open it in **lnav** by referencing it with
;INSERT INTO environ VALUES ('FILENAME', '/path/to/file')
:open $FILENAME
lnav_file
---------
The **lnav_file** table allows you to examine and perform limited updates to
the metadata for the files that are currently loaded into **lnav**. The
following columns are available in this table:
:device: The device the file is stored on.
:inode: The inode for the file on the device.
:filepath: The absolute path to the file.
:format: The log file format for the file.
:lines: The number of lines in the file.
:time_offset: The millisecond offset for timestamps. This column can be
UPDATEd to change the offset of timestamps in the file.
lnav_views
----------
@ -76,11 +97,34 @@ lnav_view_filters
The **lnav_view_filters** table allows you to manipulate the filters in the
**lnav** views. The following columns are available in this table:
:view_name: The name of the view.
:view_name: The name of the view the filter is applied to.
:filter_id: The filter identifier. This will be assigned on insertion.
:enabled: Indicates whether this filter is enabled or disabled.
:type: The type of filter, either 'in' or 'out'.
:pattern: The regular expression to filter on.
This table supports SELECT, INSERT, UPDATE, and DELETE on the table rows to
read, create, update, and delete filters for the views.
lnav_view_filter_stats
----------------------
The **lnav_view_filter_stats** table allows you to get information about how
many lines matched a given filter. The following columns are available in
this table:
:view_name: The name of the view.
:filter_id: The filter identifier.
:hits: The number of lines that matched this filter.
This table is read-only.
lnav_view_filters_and_stats
---------------------------
The **lnav_view_filters_and_stats** view joins the **lnav_view_filters** table
with the **lnav_view_filter_stats** table into a single view for ease of use.
all_logs
--------

@ -123,14 +123,14 @@ struct lnav_views : public tvt_iterator_cursor<lnav_views> {
static constexpr const char *CREATE_STMT = R"(
-- Access lnav's views through this table.
CREATE TABLE lnav_views (
name text PRIMARY KEY, -- The name of the view.
top integer, -- The number of the line at the top of the view, starting from zero.
left integer, -- The left position of the viewport.
height integer, -- The height of the viewport.
inner_height integer, -- The number of lines in the view.
top_time datetime, -- The time of the top line in the view, if the content is time-based.
paused integer, -- Indicates if the view is paused and will not load new data.
search text -- The text to search for in the view.
name TEXT PRIMARY KEY, -- The name of the view.
top INTEGER, -- The number of the line at the top of the view, starting from zero.
left INTEGER, -- The left position of the viewport.
height INTEGER, -- The height of the viewport.
inner_height INTEGER, -- The number of lines in the view.
top_time DATETIME, -- The time of the top line in the view, if the content is time-based.
paused INTEGER, -- Indicates if the view is paused and will not load new data.
search TEXT -- The text to search for in the view.
);
)";
@ -255,7 +255,7 @@ struct lnav_view_stack : public tvt_iterator_cursor<lnav_view_stack> {
static constexpr const char *CREATE_STMT = R"(
-- Access lnav's view stack through this table.
CREATE TABLE lnav_view_stack (
name text
name TEXT
);
)";
@ -415,11 +415,11 @@ struct lnav_view_filters : public tvt_iterator_cursor<lnav_view_filters>,
static constexpr const char *CREATE_STMT = R"(
-- Access lnav's filters through this table.
CREATE TABLE lnav_view_filters (
view_name text, -- The name of the view.
filter_id integer, -- The filter identifier.
enabled integer, -- Indicates if the filter is enabled/disabled.
type text, -- The type of filter (i.e. in/out).
pattern text -- The filter pattern.
view_name TEXT, -- The name of the view.
filter_id INTEGER DEFAULT 0, -- The filter identifier.
enabled INTEGER DEFAULT 1, -- Indicates if the filter is enabled/disabled.
type TEXT DEFAULT 'out', -- The type of filter (i.e. in/out).
pattern TEXT -- The filter pattern.
);
)";
@ -467,18 +467,22 @@ CREATE TABLE lnav_view_filters (
int insert_row(sqlite3_vtab *tab,
sqlite3_int64 &rowid_out,
lnav_view_t view_index,
int64_t _filter_id,
bool enabled,
text_filter::type_t type,
nonstd::optional<int64_t> _filter_id,
nonstd::optional<bool> enabled,
nonstd::optional<text_filter::type_t> type,
pair<string, pcre *> pattern) {
textview_curses &tc = lnav_data.ld_views[view_index];
text_sub_source *tss = tc.get_sub_source();
filter_stack &fs = tss->get_filters();
auto pf = make_shared<pcre_filter>(type,
pattern.first,
fs.next_index(),
pattern.second);
auto pf = make_shared<pcre_filter>(
type.value_or(text_filter::type_t::EXCLUDE),
pattern.first,
fs.next_index(),
pattern.second);
fs.add_filter(pf);
if (!enabled.value_or(true)) {
pf->disable();
}
tss->text_filters_changed();
tc.set_needs_update();

@ -46,12 +46,12 @@ run_test ${lnav_test} -n \
-c ";INSERT INTO lnav_view_filters VALUES ('log', 0 , 1, 'bad', 'abc')" \
${test_dir}/logfile_access_log.0
check_error_output "inserted filter with an empty pattern?" <<EOF
check_error_output "inserted filter with an invalid filter type?" <<EOF
error:command-option:1:Expecting an filter type for column number 3
EOF
run_test ${lnav_test} -n \
-c ";INSERT INTO lnav_view_filters VALUES ('log', 0, 1, 'out', 'vmk')" \
-c ";INSERT INTO lnav_view_filters (view_name, pattern) VALUES ('log', 'vmk')" \
${test_dir}/logfile_access_log.0
check_output "inserted filter did not work?" <<EOF

Loading…
Cancel
Save