[attr_line] text wrapping fixes for preformatted text

pull/1205/head
Tim Stack 9 months ago
parent ebbeff8ac1
commit 215d6180de

@ -111,6 +111,7 @@ Bug Fixes:
for unknown JSON properties. These extra fields are now
shown with the proper `jget(log_raw_text, '/...')` SQL
expression needed to retrieve the value.
* Improved text-wrapping when rendering Markdown.
Interface changes:
* The breadcrumb bar hotkey is moving to backtick `` ` ``

@ -200,7 +200,9 @@ attr_line_t::insert(size_t index,
this->al_string, starting_line_index, this->al_string.length());
string_fragment last_word;
ssize_t line_ch_count = 0;
ssize_t line_indent_count = 0;
auto needs_indent = false;
auto last_was_pre = false;
while (!text_to_wrap.empty()) {
if (needs_indent) {
@ -214,6 +216,7 @@ attr_line_t::insert(size_t index,
split_attrs(*this, indent_lr);
indent_lr.lr_end += tws->tws_padding_indent;
line_ch_count += tws->tws_padding_indent;
line_indent_count += tws->tws_padding_indent;
if (!indent_lr.empty()) {
this->al_attrs.emplace_back(indent_lr, SA_PREFORMATTED.value());
}
@ -222,18 +225,34 @@ attr_line_t::insert(size_t index,
tws->tws_indent + tws->tws_padding_indent);
needs_indent = false;
}
auto chunk = text_stream::consume(text_to_wrap);
text_to_wrap = chunk.match(
text_stream::chunk next_chunk(mapbox::util::no_init{});
auto pre_iter = find_string_attr_containing(
this->al_attrs, &SA_PREFORMATTED, text_to_wrap.sf_begin);
if (pre_iter != this->al_attrs.end()) {
auto pre_len = pre_iter->sa_range.lr_end - text_to_wrap.sf_begin;
auto pre_lf = text_to_wrap.find('\n');
if (pre_lf && pre_lf.value() < pre_len) {
pre_len = pre_lf.value() + 1;
}
auto pre_pair = text_to_wrap.split_n(pre_len);
next_chunk = text_stream::word{
pre_pair->first,
pre_pair->second,
};
}
if (!next_chunk.valid()) {
next_chunk = text_stream::consume(text_to_wrap);
}
text_to_wrap = next_chunk.match(
[&](text_stream::word word) {
auto ch_count
= word.w_word.utf8_length().unwrapOr(word.w_word.length());
if ((line_ch_count + ch_count) > usable_width
&& find_string_attr_containing(this->al_attrs,
&SA_PREFORMATTED,
text_to_wrap.sf_begin)
== this->al_attrs.end())
if (line_ch_count > line_indent_count && !last_was_pre
&& (line_ch_count + ch_count) > usable_width)
{
this->insert(word.w_word.sf_begin, 1, '\n');
this->insert(word.w_word.sf_begin + 1,
@ -250,6 +269,7 @@ attr_line_t::insert(size_t index,
SA_PREFORMATTED.value());
}
line_ch_count = tws->tws_padding_indent + ch_count;
line_indent_count = tws->tws_padding_indent;
auto trailing_space_count = 0;
if (!last_word.empty()) {
trailing_space_count
@ -263,12 +283,18 @@ attr_line_t::insert(size_t index,
1 + tws->tws_indent + tws->tws_padding_indent);
}
line_ch_count += ch_count;
if (word.w_word.endswith("\n")) {
line_ch_count = 0;
line_indent_count = 0;
needs_indent = true;
}
return word.w_remaining;
},
[&](text_stream::space space) {
if (space.s_value == "\n") {
line_ch_count = 0;
line_indent_count = 0;
needs_indent = true;
return space.s_remaining;
}
@ -287,6 +313,7 @@ attr_line_t::insert(size_t index,
space.s_value.length());
this->insert(space.s_value.sf_begin, "\n");
line_ch_count = 0;
line_indent_count = 0;
needs_indent = true;
auto trailing_space_count = 0;
@ -318,9 +345,10 @@ attr_line_t::insert(size_t index,
[](text_stream::corrupt corrupt) { return corrupt.c_remaining; },
[](text_stream::eof eof) { return eof.e_remaining; });
if (chunk.is<text_stream::word>()) {
if (next_chunk.is<text_stream::word>()) {
last_word = text_to_wrap;
}
last_was_pre = (pre_iter != this->al_attrs.end());
ensure(this->al_string.data() == text_to_wrap.sf_string);
ensure(text_to_wrap.sf_begin <= text_to_wrap.sf_end);

@ -98,3 +98,18 @@ TEST_CASE("attr_line_t::unicode-wrap")
" be wrapped and\n"
" indented");
}
TEST_CASE("attr_line_t::pre-wrap")
{
auto pre_al = attr_line_t(" Hello, World! ")
.with_attr_for_all(SA_PREFORMATTED.value());
auto al = attr_line_t("This is a pre-formatted inline -- ")
.append(pre_al)
.append(" -- that should be wrapped");
text_wrap_settings tws = {0, 36};
auto body = attr_line_t().append(al, &tws);
printf("body\n%s\n", body.get_string().c_str());
}

@ -453,6 +453,7 @@ println(FILE* file, const attr_line_t& al)
case role_t::VCR_LIST_GLYPH:
line_style |= fmt::fg(fmt::terminal_color::yellow);
break;
case role_t::VCR_INLINE_CODE:
case role_t::VCR_QUOTED_CODE:
default_fg_style
= fmt::fg(fmt::terminal_color::white);

@ -80,14 +80,17 @@ md2attr_line::flush_footnotes()
block_text.append("\n");
for (auto& foot : this->ml_footnotes) {
block_text.append(lnav::string::attrs::preformatted(" "))
.append("\u258c"_footnote_border)
.append(lnav::roles::footnote_text(
index < 10 && this->ml_footnotes.size() >= 10 ? " " : ""))
.append(lnav::roles::footnote_text(
fmt::format(FMT_STRING("[{}] - "), index)))
.append(foot.pad_to(longest_foot))
.append("\n");
auto footline
= attr_line_t(" ")
.append("\u258c"_footnote_border)
.append(lnav::roles::footnote_text(
index < 10 && this->ml_footnotes.size() >= 10 ? " " : ""))
.append(lnav::roles::footnote_text(
fmt::format(FMT_STRING("[{}] - "), index)))
.append(foot.pad_to(longest_foot))
.with_attr_for_all(SA_PREFORMATTED.value());
block_text.append(footline).append("\n");
index += 1;
}
this->ml_footnotes.clear();

@ -3,5 +3,5 @@
 | :filter-out 32 
 = help: :filter-out pattern
══════════════════════════════════════════════════════════════════════
Remove lines that match the given regular expression in the current
view
Remove lines that match the given regular expression in the
current view

@ -32,10 +32,10 @@ Lnav takes a list of files to view and/or you can use the flag
arguments to load well-known log files, such as the syslog log files.
The flag arguments are:
• -a Load all of the most recent log file types.
• -r Recursively load files from the given directory
•  -a  Load all of the most recent log file types.
•  -r  Recursively load files from the given directory
hierarchies.
• -R Load older rotated log files as well.
•  -R  Load older rotated log files as well.
When using the flag arguments, lnav will look for the files relative
to the current directory and its parent directories. In other words,
@ -43,7 +43,7 @@ if you are working within a directory that has the well-known log
files, those will be preferred over any others.
If you do not want the default syslog file to be loaded when no files
are specified, you can pass the -N flag.
are specified, you can pass the  -N  flag.
Any files given on the command-line are scanned to determine their log
file format and to create an index for each line in the file. You do
@ -56,25 +56,25 @@ Lnav will also display data piped in on the standard input.
To automatically execute queries or lnav commands after the files have
been loaded, you can use the following options:
• -c cmd A command, query, or file to execute. The
•  -c cmd  A command, query, or file to execute. The
first character determines the type of operation: a colon
( : ) is used for the built-in commands; a semi-colon ( ;
) for SQL queries; and a pipe symbol ( | ) for executing
a file containing other commands. For example, to open
the file "foo.log" and go to the tenth line in the file,
you can do:
( : ) is used for the built-in commands; a semi-colon (
 ; ) for SQL queries; and a pipe symbol ( | ) for
executing a file containing other commands. For example,
to open the file "foo.log" and go to the tenth line in
the file, you can do:
lnav -c ':goto 10' foo.log 
This option can be given multiple times to execute
multiple operations in sequence.
• -f file A file that contains commands, queries, or
files to execute. This option is a shortcut for -c '|file'
. You can use a dash ( - ) to execute commands from the
standard input.
•  -f file  A file that contains commands, queries, or
files to execute. This option is a shortcut for
 -c '|file' . You can use a dash ( - ) to execute
commands from the standard input.
To execute commands/queries without opening the interactive text UI,
you can pass the -n option. This combination of options allows you
you can pass the  -n  option. This combination of options allows you
to write scripts for processing logs with lnav. For example, to get a
list of IP addresses that dhclient has bound to in CSV format:
@ -99,13 +99,14 @@ The main part of the display shows the log lines from the files
interleaved based on time-of-day. New lines are automatically loaded
as they are appended to the files and, if you are viewing the bottom
of the files, lnav will scroll down to display the new lines, much
like tail -f .
like  tail -f .
On color displays, the lines will be highlighted as follows:
• Errors will be colored in red;
• warnings will be yellow;
• boundaries between days will be underlined; and
• boundaries between days will be underlined;
and
• various color highlights will be applied to: IP
addresses, SQL keywords, XML tags, file and line numbers
in Java backtraces, and quoted strings.
@ -120,29 +121,30 @@ and right-hand side of the bar, for search hits and bookmarks.
The bar on the left side indicates the file the log message is from. A
break in the bar means that the next log message comes from a
different file. The color of the bar is derived from the file name.
Pressing the left-arrow or h will reveal the source file names for
Pressing the left-arrow or  h  will reveal the source file names for
each message and pressing again will show the full paths.
Above and below the main body are status lines that display a variety
of information. The top line displays:
• The current time, configurable by the /ui/clock-format
property.
• The highest priority message from the lnav_user_notifications
table. You can insert rows into this table to display
your own status messages. The default message displayed
on startup explains how to focus on the next status line
at the top, which is an interactive breadcrumb bar.
• The current time, configurable by the
 /ui/clock-format  property.
• The highest priority message from the
 lnav_user_notifications  table. You can insert rows into
this table to display your own status messages. The
default message displayed on startup explains how to
focus on the next status line at the top, which is an
interactive breadcrumb bar.
The second status line at the top display breadcrumbs for the top line
in the main view. Pressing ENTER will focus input on the breadcrumb
in the main view. Pressing  ENTER  will focus input on the breadcrumb
bar, the cursor keys can be used to select a breadcrumb. The common
breadcrumbs are:
• The name of the current view.
• In the log view, the timestamp of the top log message.
• In the log view, the format of the log file the top log
message is from.
• In the log view, the format of the log file the top
log message is from.
• The name of the file the top line was pulled from.
• If the top line is within a larger chunk of structured
data, the path to the value in the top line will be
@ -150,8 +152,8 @@ breadcrumbs are:
Notes:
1. Pressing CTRL-A / CTRL-E will select the first/last
breadcrumb.
1. Pressing  CTRL-A / CTRL-E  will select the
first/last breadcrumb.
2. Typing text while a breadcrumb is selected will
perform a fuzzy search on the possibilities.
@ -166,7 +168,8 @@ the following:
• The number of enabled filters and the total number of
filters.
• The number of lines not displayed because of filtering.
• The number of lines not displayed because of
filtering.
To edit the filters, you can press TAB to change the focus from the
main view to the filter editor. The editor allows you to create,
@ -188,7 +191,7 @@ results. The views are organized into a stack so that any time you
activate a new view with a key press or command, the new view is
pushed onto the stack. Pressing the same key again will pop the view
off of the stack and return you to the previous view. Note that you
can always use q to pop the top view off of the stack.
can always use  q  to pop the top view off of the stack.
Default Key Bindings
@ -199,16 +202,16 @@ can always use q to pop the top view off of the stack.
? View/leave this help message.
q Leave the current view or quit the program when in
the log file view.
Q Similar to q , except it will try to sync the top
Q Similar to  q , except it will try to sync the top
time between the current and former views. For
example, when leaving the spectrogram view with Q
, the top time in that view will be matched to the
top time in the log view.
example, when leaving the spectrogram view with
 Q , the top time in that view will be matched to
the top time in the log view.
TAB Toggle focusing on the filter editor or the main
view.
ENTER Focus on the breadcrumb bar.
a/A Restore the view that was previously popped with q
/ Q . The A hotkey will try to match the top
a/A Restore the view that was previously popped with
 q / Q . The  A  hotkey will try to match the top
times between the two views.
X Close the current text file or log file.
@ -291,13 +294,13 @@ can always use q to pop the top view off of the stack.
m Mark/unmark the line at the top of the display.
The line will be highlighted with reverse video to
indicate that it is a user bookmark. You can use
the u hotkey to iterate through marks you have
the  u  hotkey to iterate through marks you have
added.
M Mark/unmark all the lines between the top of the
display and the last line marked/unmarked.
J Mark/unmark the next line after the previously
marked line.
K Like J except it toggles the mark on the
K Like  J  except it toggles the mark on the
previous line.
c Copy the marked text to the X11 selection buffer
or OS X clipboard.
@ -334,12 +337,12 @@ can always use q to pop the top view off of the stack.
log lines for each bucket of time. The bars are
layed out horizontally with colored segments
representing the different log levels. You can use
the z hotkey to change the size of the time
the  z  hotkey to change the size of the time
buckets (e.g. ten minutes, one hour, one day).
I Switch between the log and histogram views while
keeping the time displayed at the top of each view
in sync. For example, if the top line in the log
view is "11:40", hitting I will switch to the
view is "11:40", hitting  I  will switch to the
histogram view and scrolled to display "11:00" at
the top (if the zoom level is hours).
z/Shift Z Zoom in or out one step in the histogram view.
@ -415,14 +418,14 @@ can always use q to pop the top view off of the stack.
below for more information.
|<script> [arg1...] Execute an lnav script contained in a format
directory (e.g. ~/.lnav/formats/default). The
script can contain lines starting with : , ; ,
or | to execute commands, SQL queries or execute
script can contain lines starting with  : ,  ; ,
or  |  to execute commands, SQL queries or execute
other files in lnav. Any values after the script
name are treated as arguments can be referenced in
the script using $1 , $2 , and so on, like in a
the script using  $1 ,  $2 , and so on, like in a
shell script.
CTRL+], ESCAPE Abort command-line entry started with / , : , ;
, or | .
CTRL+], ESCAPE Abort command-line entry started with  / ,  : ,
 ; , or  | .
Note: The regular expression format used by lnav is ]8;;http://perldoc.perl.org/perlre.html\PCRE]8;;\[1]
▌(Perl-Compatible Regular Expressions).
@ -499,10 +502,10 @@ Some commonly used format tables are:
leading timestamp followed by the message.
NOTE: You can get a dump of the schema for the internal tables, and
any attached databases, by running the .schema SQL command.
any attached databases, by running the  .schema  SQL command.
The columns available for the top log line in the view will
automatically be displayed after pressing the semicolon ( ; ) key. All
automatically be displayed after pressing the semicolon ( ; ) key. All
log tables contain at least the following columns:
Column Description
@ -528,7 +531,7 @@ The following tables include the basic columns as listed above and
include a few more columns since the log file format is more
structured.
• syslog_log
•  syslog_log 
Column Description
═════════════════════════════════════════════════════════════════
@ -536,8 +539,8 @@ structured.
log_procname The name of the process that sent the message.
log_pid The process ID of the process that sent the
message.
• access_log (The column names are the same as those in
the Microsoft LogParser tool.)
•  access_log  (The column names are the same as those
in the Microsoft LogParser tool.)
Column Description
══════════════════════════════════════════════════════════
@ -551,8 +554,8 @@ structured.
sc_bytes The number of bytes sent to the client.
cs_referrer The URL of the referring page.
cs_user_agent The user agent string.
• strace_log (Currently, you need to run strace with
the -tt -T options so there are timestamps for each
•  strace_log  (Currently, you need to run strace with
the  -tt -T options so there are timestamps for each
function call.)
Column Description
@ -580,7 +583,7 @@ use with care.)
For log formats that lack message structure, lnav can parse the log
message and attempt to extract any data fields that it finds. This
feature is available through the logline log table. This table is
feature is available through the  logline  log table. This table is
dynamically created and defined based on the message at the top of the
log view. For example, given the following log message from "sudo",
lnav will create the "logline" table with columns for "TTY", "PWD",
@ -625,12 +628,12 @@ view as a template.
Environment variables can be used in SQL statements by prefixing the
variable name with a dollar-sign ($). For example, to read the value
of the HOME variable, you can do:
of the  HOME  variable, you can do:
;SELECT $HOME; 
To select the syslog messages that have a hostname field that is equal
to the HOSTNAME variable:
to the  HOSTNAME  variable:
;SELECT * FROM syslog_log WHERE log_hostname = $HOSTNAME; 
@ -784,9 +787,10 @@ For support questions, email:
:comment text
══════════════════════════════════════════════════════════════════════
Attach a comment to the top log line. The comment will be displayed
right below the log message it is associated with. The comment can
be formatted using markdown and you can add new-lines with '\n'.
Attach a comment to the top log line. The comment will be
displayed right below the log message it is associated with. The
comment can be formatted using markdown and you can add new-lines
with '\n'.
Parameter
text The comment text
See Also
@ -818,7 +822,8 @@ For support questions, email:
:create-logline-table table-name
══════════════════════════════════════════════════════════════════════
Create an SQL table using the top line of the log view as a template
Create an SQL table using the top line of the log view as a
template
Parameter
table-name The name for the new table
See Also
@ -836,8 +841,8 @@ For support questions, email:
Create an SQL table based on a regex search
Parameters
table-name The name of the table to create
pattern The regular expression used to capture the
table columns. If not given, the current search
pattern The regular expression used to capture
the table columns. If not given, the current search
pattern is used.
See Also
:create-logline-table, :create-logline-table, :delete-search-table,
@ -853,8 +858,8 @@ For support questions, email:
:current-time
══════════════════════════════════════════════════════════════════════
Print the current time in human-readable form and seconds since the
epoch
Print the current time in human-readable form and seconds since
the epoch
:delete-filter pattern
@ -986,7 +991,8 @@ For support questions, email:
Evaluate the given command/query after doing environment variable
substitution
Parameter
command The command or query to perform substitution on.
command The command or query to perform substitution
on.
See Also
:alt-msg, :cd, :echo, :export-session-to, :rebuild, :redirect-to, :sh,
:write-csv-to, :write-json-to, :write-jsonlines-to, :write-raw-to,
@ -999,8 +1005,8 @@ For support questions, email:
:export-session-to path
══════════════════════════════════════════════════════════════════════
Export the current lnav state to an executable lnav script file that
contains the commands needed to restore the current session
Export the current lnav state to an executable lnav script file
that contains the commands needed to restore the current session
Parameter
path The path to the file to write
See Also
@ -1049,8 +1055,8 @@ For support questions, email:
:filter-out pattern
══════════════════════════════════════════════════════════════════════
Remove lines that match the given regular expression in the current
view
Remove lines that match the given regular expression in the
current view
Parameter
pattern The regular expression to match
See Also
@ -1116,7 +1122,7 @@ For support questions, email:
:hide-file path
══════════════════════════════════════════════════════════════════════
Hide the given file(s) and skip indexing until it is shown again.
Hide the given file(s) and skip indexing until it is shown again.
If no path is given, the current file in the view is hidden
Parameter
path A path or glob pattern that specifies the files to
@ -1168,8 +1174,8 @@ For support questions, email:
:highlight pattern
══════════════════════════════════════════════════════════════════════
Add coloring to log messages fragments that match the given regular
expression
Add coloring to log messages fragments that match the given
regular expression
Parameter
pattern The regular expression to match
See Also
@ -1216,8 +1222,8 @@ For support questions, email:
══════════════════════════════════════════════════════════════════════
Move to the next bookmark of the given type in the current view
Parameter
type The type of bookmark -- error, warning, search, user,
file, meta
type The type of bookmark -- error, warning, search,
user, file, meta
See Also
:goto, :hide-unmarked-lines, :mark, :next-location, :prev-location,
:prev-mark, :prev-mark, :relative-goto
@ -1296,10 +1302,11 @@ For support questions, email:
:prev-mark type1 [... typeN]
══════════════════════════════════════════════════════════════════════
Move to the previous bookmark of the given type in the current view
Move to the previous bookmark of the given type in the current
view
Parameter
type The type of bookmark -- error, warning, search, user,
file, meta
type The type of bookmark -- error, warning, search,
user, file, meta
See Also
:goto, :hide-unmarked-lines, :mark, :next-location, :next-mark,
:next-mark, :prev-location, :relative-goto
@ -1318,8 +1325,8 @@ For support questions, email:
--alt Perform the alternate action for
this prompt by default
prompt The prompt to display
initial-value The initial value to fill in for the
prompt
initial-value The initial value to fill in for
the prompt
Examples
#1 To open the command prompt with 'filter-in' already filled in:
@ -1359,8 +1366,8 @@ For support questions, email:
Redirect the output of commands that write to stdout to the given
file
Parameter
path The path to the file to write. If not specified, the
current redirect will be cleared
path The path to the file to write. If not specified,
the current redirect will be cleared
See Also
:alt-msg, :append-to, :cd, :echo, :echo, :eval, :export-session-to,
:export-session-to, :pipe-line-to, :pipe-to, :rebuild, :sh,
@ -1514,8 +1521,8 @@ For support questions, email:
:summarize column-name
══════════════════════════════════════════════════════════════════════
Execute a SQL query that computes the characteristics of the values
in the given column
Execute a SQL query that computes the characteristics of the
values in the given column
Parameter
column-name The name of the column to analyze.
@ -1688,8 +1695,8 @@ For support questions, email:
messages to the file. In the DB view, the contents of the cells are
written to the output file.
Parameters
--view={log,db} The view to use as the source of
data
--view={log,db} The view to use as the source
of data
--anonymize Anonymize the lines
path The path to the file to write
See Also
@ -2069,8 +2076,8 @@ For support questions, email:
changes()
══════════════════════════════════════════════════════════════════════
The number of database rows that were changed, inserted, or deleted
by the most recent statement.
The number of database rows that were changed, inserted, or
deleted by the most recent statement.
char(X, ...)
@ -2191,7 +2198,8 @@ For support questions, email:
══════════════════════════════════════════════════════════════════════
Returns the date and time in this format: YYYY-MM-DD HH:MM:SS.
Parameters
timestring The string to convert to a date with time.
timestring The string to convert to a date with
time.
modifier A transformation that is applied to the
value to the left.
See Also
@ -2779,7 +2787,7 @@ For support questions, email:
json_concat(json, value, ...)
══════════════════════════════════════════════════════════════════════
Returns an array with the given values concatenated onto the end.
Returns an array with the given values concatenated onto the end.
If the initial value is null, the result will be an array with the
given elements. If the initial value is an array, the result will
be an array with the given values at the end. If the initial value
@ -3098,7 +3106,8 @@ For support questions, email:
yaml_to_json()
Example
#1 To iterate over an array:
;SELECT key,value,type,atom,fullkey,path FROM json_tree('[null,1,"two",{"three":4.5}]')
;SELECT key,value,type,atom,fullkey,path FROM
 json_tree('[null,1,"two",{"three":4.5}]')
@ -3154,7 +3163,8 @@ For support questions, email:
Returns the number of days since noon in Greenwich on November 24,
4714 B.C.
Parameters
timestring The string to convert to a date with time.
timestring The string to convert to a date with
time.
modifier A transformation that is applied to the
value to the left.
See Also
@ -3176,11 +3186,13 @@ For support questions, email:
lag(expr, [offset], [default])
══════════════════════════════════════════════════════════════════════
Returns the result of evaluating the expression against the previous
row in the partition.
Returns the result of evaluating the expression against the
previous row in the partition.
Parameters
expr The expression to execute over the previous row
offset The offset from the current row in the partition
expr The expression to execute over the previous
row
offset The offset from the current row in the
partition
default The default value if the previous row does not
exist instead of NULL
See Also
@ -3195,8 +3207,8 @@ For support questions, email:
last_value(expr)
══════════════════════════════════════════════════════════════════════
Returns the result of evaluating the expression against the last row
in the window frame.
Returns the result of evaluating the expression against the last
row in the window frame.
Parameter
expr The expression to execute over the last row
See Also
@ -3205,13 +3217,14 @@ For support questions, email:
lead(expr, [offset], [default])
══════════════════════════════════════════════════════════════════════
Returns the result of evaluating the expression against the next row
in the partition.
Returns the result of evaluating the expression against the next
row in the partition.
Parameters
expr The expression to execute over the next row
offset The offset from the current row in the partition
default The default value if the next row does not exist
instead of NULL
offset The offset from the current row in the
partition
default The default value if the next row does not
exist instead of NULL
See Also
cume_dist(), dense_rank(), first_value(), lag(), last_value(),
nth_value(), ntile(), percent_rank(), rank(), row_number()
@ -3269,12 +3282,12 @@ For support questions, email:
══════════════════════════════════════════════════════════════════════
Match a string against a pattern
Parameters
pattern The pattern to match. A percent symbol (%) will
match zero or more characters and an underscore (_) will
match a single character.
pattern The pattern to match. A percent symbol (%)
will match zero or more characters and an underscore (_)
will match a single character.
str The string to match
escape The escape character that can be used to prefix
a literal percent or underscore in the pattern.
escape The escape character that can be used to
prefix a literal percent or underscore in the pattern.
Examples
#1 To test if the string 'aabcc' contains the letter 'b':
@ -3440,8 +3453,8 @@ For support questions, email:
Returns the argument with the maximum value, or return NULL if any
argument is NULL.
Parameter
X The numbers to find the maximum of. If only one argument is
given, this function operates as an aggregate.
X The numbers to find the maximum of. If only one argument
is given, this function operates as an aggregate.
See Also
abs(), acos(), acosh(), asin(), asinh(), atan(), atan2(), atanh(),
atn2(), avg(), ceil(), degrees(), exp(), floor(), log(), log10(),
@ -3462,8 +3475,8 @@ For support questions, email:
Returns the argument with the minimum value, or return NULL if any
argument is NULL.
Parameter
X The numbers to find the minimum of. If only one argument is
given, this function operates as an aggregate.
X The numbers to find the minimum of. If only one argument
is given, this function operates as an aggregate.
See Also
abs(), acos(), acosh(), asin(), asinh(), atan(), atan2(), atanh(),
atn2(), avg(), ceil(), degrees(), exp(), floor(), log(), log10(),
@ -3481,8 +3494,8 @@ For support questions, email:
nth_value(expr, N)
══════════════════════════════════════════════════════════════════════
Returns the result of evaluating the expression against the nth row
in the window frame.
Returns the result of evaluating the expression against the nth
row in the window frame.
Parameters
expr The expression to execute over the nth row
N The row number
@ -3600,20 +3613,22 @@ For support questions, email:
parse_url(url)
══════════════════════════════════════════════════════════════════════
Parse a URL and return the components in a JSON object. Limitations:
not all URL schemes are supported and repeated query parameters are
not captured.
Parse a URL and return the components in a JSON object.
Limitations: not all URL schemes are supported and repeated query
parameters are not captured.
Parameter
url The URL to parse
Results
scheme The URL's scheme
username The name of the user specified in the URL
username The name of the user specified in the
URL
password The password specified in the URL
host The host name / IP specified in the URL
port The port specified in the URL
path The path specified in the URL
query The query string in the URL
parameters An object containing the query parameters
parameters An object containing the query
parameters
fragment The fragment specified in the URL
See Also
anonymize(), char(), charindex(), decode(), encode(), endswith(),
@ -3675,13 +3690,13 @@ For support questions, email:
printf(format, X)
══════════════════════════════════════════════════════════════════════
Returns a string with this functions arguments substituted into the
given format. Substitution points are specified using percent (%)
options, much like the standard C printf() function.
Returns a string with this functions arguments substituted into
the given format. Substitution points are specified using percent
(%) options, much like the standard C printf() function.
Parameters
format The format of the string to return.
X The argument to substitute at a given position in
the format.
X The argument to substitute at a given position
in the format.
See Also
anonymize(), char(), charindex(), decode(), encode(), endswith(),
extract(), group_concat(), group_spooky_hash(), gunzip(), gzip(),
@ -3829,13 +3844,14 @@ For support questions, email:
regex.
capture_name The name of the capture in the
regex.
capture_count The total number of captures in the
regex.
capture_count The total number of captures in
the regex.
range_start The start of the capture in the
input string.
range_stop The stop of the capture in the input
range_stop The stop of the capture in the
input string.
content The captured value from the
string.
content The captured value from the string.
See Also
anonymize(), char(), charindex(), decode(), encode(), endswith(),
extract(), group_concat(), group_spooky_hash(), gunzip(), gzip(),
@ -3952,10 +3968,11 @@ For support questions, email:
Returns a string formed by substituting the replacement string for
every occurrence of the old string in the given string.
Parameters
str The string to perform substitutions on.
str The string to perform substitutions
on.
old The string to be replaced.
replacement The string to replace any occurrences of
the old string with.
replacement The string to replace any occurrences
of the old string with.
See Also
anonymize(), char(), charindex(), decode(), encode(), endswith(),
extract(), group_concat(), group_spooky_hash(), gunzip(), gzip(),
@ -4048,8 +4065,8 @@ For support questions, email:
round(num, [digits])
══════════════════════════════════════════════════════════════════════
Returns a floating-point value rounded to the given number of digits
to the right of the decimal point.
Returns a floating-point value rounded to the given number of
digits to the right of the decimal point.
Parameters
num The value to round.
digits The number of digits to the right of the decimal
@ -4075,8 +4092,8 @@ For support questions, email:
row_number()
══════════════════════════════════════════════════════════════════════
Returns the number of the row within the current partition, starting
from 1.
Returns the number of the row within the current partition,
starting from 1.
See Also
cume_dist(), dense_rank(), first_value(), lag(), last_value(), lead(),
nth_value(), ntile(), percent_rank(), rank()
@ -4123,8 +4140,8 @@ For support questions, email:
standard input.
options A JSON object containing options for the
execution with the following properties:
env - An object containing the environment variables to
set or, if NULL, to unset.
env - An object containing the environment
variables to set or, if NULL, to unset.
See Also
@ -4154,10 +4171,10 @@ For support questions, email:
sparkline(value, [upper])
══════════════════════════════════════════════════════════════════════
Function used to generate a sparkline bar chart. The non-aggregate
version converts a single numeric value on a range to a bar chart
character. The aggregate version returns a string with a bar
character for every numeric input
Function used to generate a sparkline bar chart. The
non-aggregate version converts a single numeric value on a range to
a bar chart character. The aggregate version returns a string with
a bar character for every numeric input
Parameters
value The numeric value to convert
upper The upper bound of the numeric range. The
@ -4218,8 +4235,8 @@ For support questions, email:
sqlite_compileoption_get(N)
══════════════════════════════════════════════════════════════════════
Returns the N-th compile-time option used to build SQLite or NULL if
N is out of range.
Returns the N-th compile-time option used to build SQLite or NULL
if N is out of range.
Parameter
N The option number to get
@ -4239,8 +4256,8 @@ For support questions, email:
sqlite_source_id()
══════════════════════════════════════════════════════════════════════
Returns a string that identifies the specific version of the source
code that was used to build the SQLite library.
Returns a string that identifies the specific version of the
source code that was used to build the SQLite library.
sqlite_version()
@ -4315,12 +4332,14 @@ For support questions, email:
strftime(format, timestring, modifier, ...)
══════════════════════════════════════════════════════════════════════
Returns the date formatted according to the format string specified
as the first argument.
Returns the date formatted according to the format string
specified as the first argument.
Parameters
format A format string with substitutions similar
to those found in the strftime() standard C library.
timestring The string to convert to a date with time.
format A format string with substitutions
similar to those found in the strftime() standard C
library.
timestring The string to convert to a date with
time.
modifier A transformation that is applied to the
value to the left.
See Also
@ -4449,8 +4468,8 @@ For support questions, email:
timeslice(time, slice)
══════════════════════════════════════════════════════════════════════
Return the start of the slice of time that the given timestamp falls
in. If the time falls outside of the slice, NULL is returned.
Return the start of the slice of time that the given timestamp
falls in. If the time falls outside of the slice, NULL is returned.
Parameters
time The timestamp to get the time slice for.
slice The size of the time slices
@ -4492,8 +4511,8 @@ For support questions, email:
total_changes()
══════════════════════════════════════════════════════════════════════
Returns the number of row changes caused by INSERT, UPDATE or DELETE
statements since the current database connection was opened.
Returns the number of row changes caused by INSERT, UPDATE or
DELETE statements since the current database connection was opened.
trim(str, [chars])
@ -4625,9 +4644,10 @@ For support questions, email:
xmldoc The XML document as a string.
Results
result The result of the XPATH expression.
node_path The absolute path to the node containing the
result.
node_attr The node's attributes stored in JSON object.
node_path The absolute path to the node containing
the result.
node_attr The node's attributes stored in JSON
object.
node_text The node's text value.
See Also
anonymize(), char(), charindex(), decode(), encode(), endswith(),
@ -4645,11 +4665,13 @@ For support questions, email:
#2 To select all 'a' attributes on the path '/abc/def':
;SELECT * FROM xpath('/abc/def/@a', '<abc><def a="b">Hello</def><def>Bye</def></abc>')
;SELECT * FROM xpath('/abc/def/@a', '<abc><def
 a="b">Hello</def><def>Bye</def></abc>')
#3 To select the text nodes on the path '/abc/def':
;SELECT * FROM xpath('/abc/def/text()', '<abc><def a="b">Hello &#x2605;</def></abc>')
;SELECT * FROM xpath('/abc/def/text()', '<abc><def a="b">Hello
 &#x2605;</def></abc>')
@ -4682,7 +4704,8 @@ For support questions, email:
Attach a database file to the current connection.
Parameters
filename The path to the database file.
schema-name The prefix for tables in this database.
schema-name The prefix for tables in this
database.
Example
#1 To attach the database file '/tmp/customers.db' with the name customers:
@ -4698,8 +4721,8 @@ For support questions, email:
Parameters
base-expr The base expression that is used for
comparison in the branches
cmp-expr The expression to test if this branch should
be taken
cmp-expr The expression to test if this branch
should be taken
then-expr - The result for this branch.
else-expr The result of this CASE if no branches
matched.
@ -4714,8 +4737,8 @@ For support questions, email:
══════════════════════════════════════════════════════════════════════
Assign a name to a SELECT statement
Parameters
IF NOT EXISTS Do not create the view if it already
exists
IF NOT EXISTS Do not create the view if it
already exists
schema-name. The database to create the view in
view-name The name of the view
select-stmt The SELECT statement the view
@ -4734,7 +4757,8 @@ For support questions, email:
══════════════════════════════════════════════════════════════════════
Detach a database from the current connection.
Parameter
schema-name The prefix for tables in this database.
schema-name The prefix for tables in this
database.
Example
#1 To detach the database named 'customers':
@ -4776,10 +4800,10 @@ For support questions, email:
table The table(s) to query for data
cond The conditions used to select the
rows to return.
grouping-expr The expression to use when grouping
rows.
ordering-term The values to use when ordering the
result set.
grouping-expr The expression to use when
grouping rows.
ordering-term The values to use when ordering
the result set.
limit-expr The maximum number of rows to
return.
@ -4795,9 +4819,10 @@ For support questions, email:
Parameters
table The table to update
column-name The columns in the table to update.
expr - The values to place into the column.
cond The condition used to determine whether
a row should be updated.
expr - The values to place into the
column.
cond The condition used to determine
whether a row should be updated.
Example
#1 To mark the syslog message at line 40:
@ -4810,6 +4835,7 @@ For support questions, email:
Create a temporary view that exists only for the duration of a SQL
statement.
Parameters
cte-table-name The name for the temporary table.
cte-table-name The name for the temporary
table.
select-stmt The SELECT statement used to
populate the temporary table.

@ -1,6 +1,6 @@
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
Hello, World!
This is  markdown  now!
This is  markdown  now!
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"

@ -3,7 +3,7 @@
Lnav follows the usual GNU style for configuring and installing
software:
Run ./autogen.sh if compiling from a cloned repository.
Run  ./autogen.sh  if compiling from a cloned repository.
$ ./configure 
$ make 

@ -38,8 +38,8 @@ with highlights. Errors are red and warnings are yellow.
Features
• Log messages from different files are collated together
into a single view
• Log messages from different files are collated
together into a single view
• Automatic detection of log format
• Automatic decompression of GZip and BZip2 files
• Filter log messages based on regular expressions
@ -55,7 +55,7 @@ with highlights. Errors are red and warnings are yellow.
Usage
The only file installed is the executable, lnav . You can execute it
The only file installed is the executable,  lnav . You can execute it
with no arguments to view the default set of files:
$ lnav 
@ -64,9 +64,9 @@ You can view all the syslog messages by running:
$ lnav /var/log/messages* 
Usage with  systemd-journald 
Usage with  systemd-journald 
On systems running systemd-journald , you can use lnav as the
On systems running  systemd-journald , you can use  lnav  as the
pager:
$ journalctl | lnav 
@ -75,35 +75,36 @@ or in follow mode:
$ journalctl -f | lnav 
Since journalctl 's default output format omits the year, if you are
Since  journalctl 's default output format omits the year, if you are
viewing logs which span multiple years you will need to change the
output format to include the year, otherwise lnav gets confused:
output format to include the year, otherwise  lnav  gets confused:
$ journalctl -o short-iso | lnav 
It is also possible to use journalctl 's json output format and lnav
will make use of additional fields such as PRIORITY and _SYSTEMD_UNIT:
It is also possible to use  journalctl 's json output format and
 lnav will make use of additional fields such as PRIORITY and
_SYSTEMD_UNIT:
$ journalctl -o json | lnav 
In case some MESSAGE fields contain special characters such as ANSI
color codes which are considered as unprintable by journalctl,
specifying journalctl 's -a option might be preferable in order to
specifying  journalctl 's  -a  option might be preferable in order to
output those messages still in a non-binary representation:
$ journalctl -a -o json | lnav 
If using systemd v236 or newer, the output fields can be limited to
the ones actually recognized by lnav for increased efficiency:
the ones actually recognized by  lnav  for increased efficiency:
$ journalctl -o json --output-fields=MESSAGE,PRIORITY,_PID,SYSLOG_IDENTIFIER,_SYSTEMD_UNIT | lnav 
If your system has been running for a long time, for increased
efficiency you may want to limit the number of log lines fed into lnav
, e.g. via journalctl 's -n or --since=... options.
efficiency you may want to limit the number of log lines fed into
 lnav , e.g. via  journalctl 's  -n  or  --since=...  options.
In case of a persistent journal, you may want to limit the number of
log lines fed into lnav via journalctl 's -b option.
log lines fed into  lnav  via  journalctl 's  -b  option.
Support
@ -143,16 +144,16 @@ The following software packages are required to build lnav:
• gcc/clang - A C++14-compatible compiler.
• libpcre2 - The Perl Compatible Regular Expression v2
(PCRE2) library.
• sqlite - The SQLite database engine. Version 3.9.0
or higher is required.
• sqlite - The SQLite database engine. Version
3.9.0 or higher is required.
• ncurses - The ncurses text UI library.
• readline - The readline line editing library.
• zlib - The zlib compression library.
• bz2 - The bzip2 compression library.
• libcurl - The cURL library for downloading files
from URLs. Version 7.23.0 or higher is required.
• libarchive - The libarchive library for opening archive
files, like zip/tgz.
• libarchive - The libarchive library for opening
archive files, like zip/tgz.
• wireshark - The 'tshark' program is used to interpret
pcap files.
@ -161,7 +162,7 @@ The following software packages are required to build lnav:
Lnav follows the usual GNU style for configuring and installing
software:
Run ./autogen.sh if compiling from a cloned repository.
Run  ./autogen.sh  if compiling from a cloned repository.
$ ./configure 
$ make 

@ -10,8 +10,8 @@ with highlights. Errors are red and warnings are yellow.
Features
• Log messages from different files are collated together
into a single view
• Log messages from different files are collated
together into a single view
• Automatic detection of log format
• Automatic decompression of GZip and BZip2 files
• Filter log messages based on regular expressions
@ -27,7 +27,7 @@ with highlights. Errors are red and warnings are yellow.
Usage
The only file installed is the executable, lnav . You can execute it
The only file installed is the executable,  lnav . You can execute it
with no arguments to view the default set of files:
$ lnav 
@ -36,9 +36,9 @@ You can view all the syslog messages by running:
$ lnav /var/log/messages* 
Usage with  systemd-journald 
Usage with  systemd-journald 
On systems running systemd-journald , you can use lnav as the
On systems running  systemd-journald , you can use  lnav  as the
pager:
$ journalctl | lnav 
@ -47,35 +47,36 @@ or in follow mode:
$ journalctl -f | lnav 
Since journalctl 's default output format omits the year, if you are
Since  journalctl 's default output format omits the year, if you are
viewing logs which span multiple years you will need to change the
output format to include the year, otherwise lnav gets confused:
output format to include the year, otherwise  lnav  gets confused:
$ journalctl -o short-iso | lnav 
It is also possible to use journalctl 's json output format and lnav
will make use of additional fields such as PRIORITY and _SYSTEMD_UNIT:
It is also possible to use  journalctl 's json output format and
 lnav will make use of additional fields such as PRIORITY and
_SYSTEMD_UNIT:
$ journalctl -o json | lnav 
In case some MESSAGE fields contain special characters such as ANSI
color codes which are considered as unprintable by journalctl,
specifying journalctl 's -a option might be preferable in order to
specifying  journalctl 's  -a  option might be preferable in order to
output those messages still in a non-binary representation:
$ journalctl -a -o json | lnav 
If using systemd v236 or newer, the output fields can be limited to
the ones actually recognized by lnav for increased efficiency:
the ones actually recognized by  lnav  for increased efficiency:
$ journalctl -o json --output-fields=MESSAGE,PRIORITY,_PID,SYSLOG_IDENTIFIER,_SYSTEMD_UNIT | lnav 
If your system has been running for a long time, for increased
efficiency you may want to limit the number of log lines fed into lnav
, e.g. via journalctl 's -n or --since=... options.
efficiency you may want to limit the number of log lines fed into
 lnav , e.g. via  journalctl 's  -n  or  --since=...  options.
In case of a persistent journal, you may want to limit the number of
log lines fed into lnav via journalctl 's -b option.
log lines fed into  lnav  via  journalctl 's  -b  option.
Support
@ -115,16 +116,16 @@ The following software packages are required to build lnav:
• gcc/clang - A C++14-compatible compiler.
• libpcre2 - The Perl Compatible Regular Expression v2
(PCRE2) library.
• sqlite - The SQLite database engine. Version 3.9.0
or higher is required.
• sqlite - The SQLite database engine. Version
3.9.0 or higher is required.
• ncurses - The ncurses text UI library.
• readline - The readline line editing library.
• zlib - The zlib compression library.
• bz2 - The bzip2 compression library.
• libcurl - The cURL library for downloading files
from URLs. Version 7.23.0 or higher is required.
• libarchive - The libarchive library for opening archive
files, like zip/tgz.
• libarchive - The libarchive library for opening
archive files, like zip/tgz.
• wireshark - The 'tshark' program is used to interpret
pcap files.
@ -133,7 +134,7 @@ The following software packages are required to build lnav:
Lnav follows the usual GNU style for configuring and installing
software:
Run ./autogen.sh if compiling from a cloned repository.
Run  ./autogen.sh  if compiling from a cloned repository.
$ ./configure 
$ make 

@ -10,8 +10,8 @@ with highlights. Errors are red and warnings are yellow.
Features
• Log messages from different files are collated together
into a single view
• Log messages from different files are collated
together into a single view
• Automatic detection of log format
• Automatic decompression of GZip and BZip2 files
• Filter log messages based on regular expressions
@ -27,7 +27,7 @@ with highlights. Errors are red and warnings are yellow.
Usage
The only file installed is the executable, lnav . You can execute it
The only file installed is the executable,  lnav . You can execute it
with no arguments to view the default set of files:
$ lnav 
@ -36,9 +36,9 @@ You can view all the syslog messages by running:
$ lnav /var/log/messages* 
Usage with  systemd-journald 
Usage with  systemd-journald 
On systems running systemd-journald , you can use lnav as the
On systems running  systemd-journald , you can use  lnav  as the
pager:
$ journalctl | lnav 
@ -47,35 +47,36 @@ or in follow mode:
$ journalctl -f | lnav 
Since journalctl 's default output format omits the year, if you are
Since  journalctl 's default output format omits the year, if you are
viewing logs which span multiple years you will need to change the
output format to include the year, otherwise lnav gets confused:
output format to include the year, otherwise  lnav  gets confused:
$ journalctl -o short-iso | lnav 
It is also possible to use journalctl 's json output format and lnav
will make use of additional fields such as PRIORITY and _SYSTEMD_UNIT:
It is also possible to use  journalctl 's json output format and
 lnav will make use of additional fields such as PRIORITY and
_SYSTEMD_UNIT:
$ journalctl -o json | lnav 
In case some MESSAGE fields contain special characters such as ANSI
color codes which are considered as unprintable by journalctl,
specifying journalctl 's -a option might be preferable in order to
specifying  journalctl 's  -a  option might be preferable in order to
output those messages still in a non-binary representation:
$ journalctl -a -o json | lnav 
If using systemd v236 or newer, the output fields can be limited to
the ones actually recognized by lnav for increased efficiency:
the ones actually recognized by  lnav  for increased efficiency:
$ journalctl -o json --output-fields=MESSAGE,PRIORITY,_PID,SYSLOG_IDENTIFIER,_SYSTEMD_UNIT | lnav 
If your system has been running for a long time, for increased
efficiency you may want to limit the number of log lines fed into lnav
, e.g. via journalctl 's -n or --since=... options.
efficiency you may want to limit the number of log lines fed into
 lnav , e.g. via  journalctl 's  -n  or  --since=...  options.
In case of a persistent journal, you may want to limit the number of
log lines fed into lnav via journalctl 's -b option.
log lines fed into  lnav  via  journalctl 's  -b  option.
Support
@ -115,16 +116,16 @@ The following software packages are required to build lnav:
• gcc/clang - A C++14-compatible compiler.
• libpcre2 - The Perl Compatible Regular Expression v2
(PCRE2) library.
• sqlite - The SQLite database engine. Version 3.9.0
or higher is required.
• sqlite - The SQLite database engine. Version
3.9.0 or higher is required.
• ncurses - The ncurses text UI library.
• readline - The readline line editing library.
• zlib - The zlib compression library.
• bz2 - The bzip2 compression library.
• libcurl - The cURL library for downloading files
from URLs. Version 7.23.0 or higher is required.
• libarchive - The libarchive library for opening archive
files, like zip/tgz.
• libarchive - The libarchive library for opening
archive files, like zip/tgz.
• wireshark - The 'tshark' program is used to interpret
pcap files.
@ -133,7 +134,7 @@ The following software packages are required to build lnav:
Lnav follows the usual GNU style for configuring and installing
software:
Run ./autogen.sh if compiling from a cloned repository.
Run  ./autogen.sh  if compiling from a cloned repository.
$ ./configure 
$ make 

Loading…
Cancel
Save