mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[cmds] change :write-raw-to to copy the original log content and add :write-view-to command
Also added log_raw_text column to the log tables. Fixes #859
This commit is contained in:
parent
b64342ca47
commit
e13816a8e3
6
NEWS
6
NEWS
@ -79,6 +79,12 @@ lnav v0.9.1:
|
||||
* The DB view will limit the maximum column width to 120 characters.
|
||||
* The ":echo" command now evaluates its message to do variable
|
||||
substitution.
|
||||
* The ":write-raw-to" command has been changed to write the original
|
||||
log file content of marked lines. For example, when viewing a JSON
|
||||
log, the JSON-Line values from the log file will be written to the
|
||||
output file. The ":write-view-to" command has been added to perform
|
||||
the previous work of ":write-raw-to" where the raw content of the view
|
||||
is written to the file.
|
||||
|
||||
Fixes:
|
||||
* Unicode text can now be entered in prompts.
|
||||
|
@ -23,7 +23,8 @@ These columns would be available for its row in the :code:`access_log` table:
|
||||
|
||||
.. note:: Some columns are hidden by default to reduce the amount of noise in
|
||||
results, but they can still be accessed when explicitly used. The hidden
|
||||
columns are: :code:`log_path`, :code:`log_text`, and :code:`log_body`.
|
||||
columns are: :code:`log_path`, :code:`log_text`, :code:`log_body`, and
|
||||
:code:`log_raw_text`.
|
||||
|
||||
You can activate the SQL prompt by pressing the :kbd:`;` key. At the
|
||||
prompt, you can start typing in the desired SQL statement and/or double-tap
|
||||
@ -70,6 +71,56 @@ The DB view has the following display features:
|
||||
The display will show the value and JSON-Pointer path that can be passed to
|
||||
the `jget`_ function.
|
||||
|
||||
|
||||
Log Tables
|
||||
----------
|
||||
|
||||
Each log format has its own database table that can be used to access log
|
||||
messages that match that format. The table name is the same as the format
|
||||
name, for example, the :code:`syslog_log` format will have a table that is
|
||||
also named :code:`syslog_log`. There is also an :code:`all_logs` table
|
||||
that provides access to all messages from all formats.
|
||||
|
||||
.. note:: Only the displayed log messages are reflected in the SQLite
|
||||
interface. Any log messages that have been filtered out are not
|
||||
accessible.
|
||||
|
||||
The columns in the log tables are made up of several builtins along with
|
||||
the values captured by the log format specification. Use the :code:`.schema`
|
||||
command in the SQL prompt to examine a dump of the current database schema.
|
||||
|
||||
The following columns are builtin and included in a :code:`SELECT *`:
|
||||
|
||||
:log_line: The line number for the message in the log view.
|
||||
:log_part: The partition the message is in. This column can be changed by
|
||||
an :code:`UPDATE` or the :ref:`:parition-name<partition_name>` command.
|
||||
:log_time: The adjusted timestamp for the log message. This time can differ
|
||||
from the log message's time stamp if it arrived out-of-order and the log
|
||||
format expects log files to be time-ordered.
|
||||
:log_actual_time: The log messages original timestamp in the file.
|
||||
:log_idle_msecs: The difference in time between this messages and the
|
||||
previous. The unit of time is milliseconds.
|
||||
:log_level: The log message level.
|
||||
:log_mark: True if the log message was marked by the user.
|
||||
:log_comment: The comment for the message. This column can be changed by
|
||||
an :code:`UPDATE` or the :ref:`:comment<comment>` command.
|
||||
:log_tags: A JSON list of tags for the message. This column can be changed
|
||||
by an :code:`UPDATE` or the :ref:`:tag<tag>` command.
|
||||
:log_filters: A JSON list of filter IDs that matched this message
|
||||
|
||||
The following columns are builtin and are hidden, so they will *not* be
|
||||
included in a :code:`SELECT *`:
|
||||
|
||||
:log_time_msecs: The adjusted timestamp for the log message as the number of
|
||||
milliseconds from the epoch. This column can be more efficient to use for
|
||||
time-related operations, like :ref:`timeslice()<timeslice>`.
|
||||
:log_path: The path to the log file this message is from.
|
||||
:log_text: The full text of the log message.
|
||||
:log_body: The body of the log message.
|
||||
:log_raw_text: The raw text of this message from the log file. In this case
|
||||
of JSON and CSV logs, this will be the exact line of JSON-Line and CSV
|
||||
text from the file.
|
||||
|
||||
Extensions
|
||||
----------
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "readline_highlighters.hh"
|
||||
#include "vtab_module_json.hh"
|
||||
#include "log_format_ext.hh"
|
||||
#include "log_vtab_impl.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -361,7 +362,7 @@ void field_overlay_source::build_field_lines(const listview_curses &lv)
|
||||
return;
|
||||
}
|
||||
|
||||
this->fos_known_key_size = 0;
|
||||
this->fos_known_key_size = LOG_BODY.length();
|
||||
this->fos_unknown_key_size = 0;
|
||||
|
||||
for (auto & ldh_line_value : this->fos_log_helper.ldh_line_values) {
|
||||
@ -434,7 +435,7 @@ void field_overlay_source::build_field_lines(const listview_curses &lv)
|
||||
std::string field_name, orig_field_name;
|
||||
if (lv.lv_meta.lvm_struct_name.empty()) {
|
||||
if (curr_elf && curr_elf->elf_body_field == lv.lv_meta.lvm_name) {
|
||||
field_name = "log_body";
|
||||
field_name = LOG_BODY;
|
||||
} else {
|
||||
field_name = lv.lv_meta.lvm_name.to_string();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
:alt-msg Press t to switch to the text view
|
||||
|
||||
**See Also**
|
||||
:ref:`echo`, :ref:`eval`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`
|
||||
:ref:`echo`, :ref:`eval`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
:append-to /tmp/interesting-lines.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`echo`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`
|
||||
:ref:`echo`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -227,7 +227,7 @@
|
||||
:create-logline-table task_durations
|
||||
|
||||
**See Also**
|
||||
:ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`
|
||||
:ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -251,7 +251,7 @@
|
||||
:create-search-table task_durations duration=(?<duration>\d+)
|
||||
|
||||
**See Also**
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`delete_search_table`, :ref:`delete_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`delete_search_table`, :ref:`delete_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -308,7 +308,7 @@
|
||||
:delete-logline-table task_durations
|
||||
|
||||
**See Also**
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -331,7 +331,7 @@
|
||||
:delete-search-table task_durations
|
||||
|
||||
**See Also**
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`
|
||||
:ref:`create_logline_table`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`create_search_table`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -413,7 +413,7 @@
|
||||
:echo Hello, World!
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -472,7 +472,7 @@
|
||||
:eval ;SELECT * FROM ${table}
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`echo`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`echo`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -884,7 +884,7 @@
|
||||
:pipe-line-to sed -e 's/foo/bar/g'
|
||||
|
||||
**See Also**
|
||||
:ref:`append_to`, :ref:`echo`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`
|
||||
:ref:`append_to`, :ref:`echo`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -907,7 +907,7 @@
|
||||
:pipe-to sed -e s/foo/bar/g
|
||||
|
||||
**See Also**
|
||||
:ref:`append_to`, :ref:`echo`, :ref:`pipe_line_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`
|
||||
:ref:`append_to`, :ref:`echo`, :ref:`pipe_line_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1029,7 +1029,7 @@
|
||||
:redirect-to /tmp/script-output.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1406,7 +1406,7 @@
|
||||
:write-table-to /tmp/table.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1429,7 +1429,7 @@
|
||||
:write-csv-to /tmp/table.csv
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1452,7 +1452,7 @@
|
||||
:write-json-to /tmp/table.json
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1475,7 +1475,7 @@
|
||||
:write-jsonlines-to /tmp/table.json
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1485,20 +1485,20 @@
|
||||
:write-raw-to *path*
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Write the text in the top view to the given file without any formatting
|
||||
In the log view, write the original log file content of the marked messages to the file. In the DB view, the contents of the cells are written to the output file.
|
||||
|
||||
**Parameters**
|
||||
* **path\*** --- The path to the file to write
|
||||
|
||||
**Examples**
|
||||
To write the top view to /tmp/table.txt:
|
||||
To write the marked lines in the log view to /tmp/table.txt:
|
||||
|
||||
.. code-block:: lnav
|
||||
|
||||
:write-raw-to /tmp/table.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1521,7 +1521,7 @@
|
||||
:write-screen-to /tmp/table.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`, :ref:`write_view_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
@ -1544,7 +1544,30 @@
|
||||
:write-to /tmp/interesting-lines.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_view_to`, :ref:`write_view_to`
|
||||
|
||||
----
|
||||
|
||||
|
||||
.. _write_view_to:
|
||||
|
||||
:write-view-to *path*
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Write the text in the top view to the given file without any formatting
|
||||
|
||||
**Parameters**
|
||||
* **path\*** --- The path to the file to write
|
||||
|
||||
**Examples**
|
||||
To write the top view to /tmp/table.txt:
|
||||
|
||||
.. code-block:: lnav
|
||||
|
||||
:write-view-to /tmp/table.txt
|
||||
|
||||
**See Also**
|
||||
:ref:`alt_msg`, :ref:`append_to`, :ref:`create_logline_table`, :ref:`create_search_table`, :ref:`echo`, :ref:`echo`, :ref:`eval`, :ref:`pipe_line_to`, :ref:`pipe_to`, :ref:`redirect_to`, :ref:`redirect_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_csv_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_json_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_jsonlines_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_raw_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_screen_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_table_to`, :ref:`write_to`, :ref:`write_to`
|
||||
|
||||
----
|
||||
|
||||
|
@ -832,7 +832,10 @@ static Result<string, string> com_save_to(exec_context &ec, string cmdline, vect
|
||||
return ec.make_error("no query result to write, use ';' to execute a query");
|
||||
}
|
||||
}
|
||||
else if (args[0] != "write-raw-to" && args[0] != "write-screen-to") {
|
||||
else if (args[0] == "write-raw-to" && tc == &lnav_data.ld_views[LNV_DB]) {
|
||||
}
|
||||
else if (args[0] != "write-screen-to" &&
|
||||
args[0] != "write-view-to") {
|
||||
all_user_marks = combined_user_marks(tc->get_bookmarks());
|
||||
if (all_user_marks.empty()) {
|
||||
return ec.make_error("no lines marked to write, use 'm' to mark lines");
|
||||
@ -1083,24 +1086,68 @@ static Result<string, string> com_save_to(exec_context &ec, string cmdline, vect
|
||||
|
||||
line_count += 1;
|
||||
}
|
||||
} else {
|
||||
bool wrapped = tc->get_word_wrap();
|
||||
auto tss = tc->get_sub_source();
|
||||
} else if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
||||
nonstd::optional<std::pair<logfile *, content_line_t>> last_line;
|
||||
bookmark_vector<vis_line_t> visited;
|
||||
auto &lss = lnav_data.ld_log_source;
|
||||
vector<attr_line_t> rows(1);
|
||||
size_t count = 0;
|
||||
string line;
|
||||
|
||||
tc->set_word_wrap(to_term);
|
||||
for (auto iter = all_user_marks.begin();
|
||||
iter != all_user_marks.end();
|
||||
iter++, count++) {
|
||||
if (ec.ec_dry_run && count > 10) {
|
||||
break;
|
||||
}
|
||||
auto cl = lss.at(*iter);
|
||||
auto lf = lss.find(cl);
|
||||
auto lf_iter = lf->begin() + cl;
|
||||
|
||||
for (size_t lpc = 0; lpc < tss->text_line_count(); lpc++) {
|
||||
string line;
|
||||
while (lf_iter->get_sub_offset() != 0) {
|
||||
--lf_iter;
|
||||
}
|
||||
|
||||
tss->text_value_for_line(*tc, lpc, line, text_sub_source::RF_RAW);
|
||||
fprintf(outfile, "%s\n", line.c_str());
|
||||
auto line_pair = std::make_pair(
|
||||
lf.get(), content_line_t(std::distance(lf->begin(), lf_iter)));
|
||||
if (last_line && last_line.value() == line_pair) {
|
||||
continue;
|
||||
}
|
||||
last_line = line_pair;
|
||||
auto read_res = lf->read_raw_message(lf_iter);
|
||||
if (read_res.isErr()) {
|
||||
log_error("unable to read message: %s",
|
||||
read_res.unwrapErr().c_str());
|
||||
continue;
|
||||
}
|
||||
auto sbr = read_res.unwrap();
|
||||
fprintf(outfile, "%.*s\n", (int) sbr.length(), sbr.get_data());
|
||||
|
||||
line_count += 1;
|
||||
}
|
||||
|
||||
tc->set_word_wrap(wrapped);
|
||||
}
|
||||
}
|
||||
else if (args[0] == "write-view-to") {
|
||||
bool wrapped = tc->get_word_wrap();
|
||||
auto tss = tc->get_sub_source();
|
||||
|
||||
tc->set_word_wrap(to_term);
|
||||
|
||||
for (size_t lpc = 0; lpc < tss->text_line_count(); lpc++) {
|
||||
if (ec.ec_dry_run && lpc >= 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
string line;
|
||||
|
||||
tss->text_value_for_line(*tc, lpc, line, text_sub_source::RF_RAW);
|
||||
fprintf(outfile, "%s\n", line.c_str());
|
||||
|
||||
line_count += 1;
|
||||
}
|
||||
|
||||
tc->set_word_wrap(wrapped);
|
||||
}
|
||||
else {
|
||||
vector<attr_line_t> rows(1);
|
||||
size_t count = 0;
|
||||
@ -5073,13 +5120,29 @@ readline_context::command_t STD_COMMANDS[] = {
|
||||
com_save_to,
|
||||
|
||||
help_text(":write-raw-to")
|
||||
.with_summary(
|
||||
"In the log view, write the original log file content "
|
||||
"of the marked messages to the file. In the DB view, "
|
||||
"the contents of the cells are written to the output file.")
|
||||
.with_parameter(help_text("path", "The path to the file to write"))
|
||||
.with_tags({"io", "scripting", "sql"})
|
||||
.with_example({
|
||||
"To write the marked lines in the log view to /tmp/table.txt",
|
||||
"/tmp/table.txt"
|
||||
})
|
||||
},
|
||||
{
|
||||
"write-view-to",
|
||||
com_save_to,
|
||||
|
||||
help_text(":write-view-to")
|
||||
.with_summary("Write the text in the top view to the given file without any formatting")
|
||||
.with_parameter(help_text("path", "The path to the file to write"))
|
||||
.with_tags({"io", "scripting", "sql"})
|
||||
.with_example({
|
||||
"To write the top view to /tmp/table.txt",
|
||||
"/tmp/table.txt"
|
||||
})
|
||||
"To write the top view to /tmp/table.txt",
|
||||
"/tmp/table.txt"
|
||||
})
|
||||
},
|
||||
{
|
||||
"write-screen-to",
|
||||
|
@ -63,7 +63,8 @@ static const char *LOG_FOOTER_COLUMNS = R"(
|
||||
log_time_msecs INTEGER HIDDEN, -- The adjusted timestamp for the log message as the number of milliseconds from the epoch
|
||||
log_path TEXT HIDDEN COLLATE naturalnocase, -- The path to the log file this message is from
|
||||
log_text TEXT HIDDEN, -- The full text of the log message
|
||||
log_body TEXT HIDDEN -- The body of the log message
|
||||
log_body TEXT HIDDEN, -- The body of the log message
|
||||
log_raw_text TEXT HIDDEN -- The raw text from the log file
|
||||
);
|
||||
)";
|
||||
|
||||
@ -564,6 +565,22 @@ static int vt_column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int col)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
auto read_res = lf->read_raw_message(ll);
|
||||
|
||||
if (read_res.isErr()) {
|
||||
auto msg = fmt::format("unable to read line -- {}",
|
||||
read_res.unwrapErr());
|
||||
sqlite3_result_error(ctx, msg.c_str(), msg.length());
|
||||
} else {
|
||||
auto sbr = read_res.unwrap();
|
||||
|
||||
sqlite3_result_text(ctx,
|
||||
sbr.get_data(), sbr.length(),
|
||||
SQLITE_TRANSIENT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -72,6 +72,8 @@ struct log_cursor {
|
||||
};
|
||||
};
|
||||
|
||||
const std::string LOG_BODY = "log_body";
|
||||
|
||||
class log_vtab_impl {
|
||||
public:
|
||||
struct vtab_column {
|
||||
|
@ -83,7 +83,7 @@ EOF
|
||||
|
||||
|
||||
run_test ${lnav_test} -n -d /tmp/lnav.err \
|
||||
-c ":write-raw-to -" \
|
||||
-c ":write-view-to -" \
|
||||
"${test_dir}/logfile_access_log.0"
|
||||
|
||||
check_output "writing raw log does not work?" <<EOF
|
||||
|
@ -153,6 +153,28 @@ log_line,log_part,log_time,log_idle_msecs,log_level,log_mark,log_comment,log_tag
|
||||
25,<NULL>,2013-09-06 22:01:49.124,0,fatal,0,<NULL>,<NULL>,<NULL>,"[""hi"", {""sub1"": true}]","{ ""field1"" : ""hi"", ""field2"": 2 }",<NULL>
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-I ${test_dir} \
|
||||
-c ';select log_raw_text from test_log' \
|
||||
-c ':write-raw-to -' \
|
||||
${test_dir}/logfile_json.json
|
||||
|
||||
check_output "log levels not working" < ${test_dir}logfile_json.json
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-I ${test_dir} \
|
||||
-c ':goto 0' \
|
||||
-c ':mark' \
|
||||
-c ':goto 1' \
|
||||
-c ':mark' \
|
||||
-c ':goto 2' \
|
||||
-c ':mark' \
|
||||
-c ':write-raw-to -' \
|
||||
${test_dir}/log.clog
|
||||
|
||||
check_output "write-raw-to with json is not working" <<'EOF'
|
||||
{"@timestamp":"2016-08-03T12:06:31.009-0500","@version":1,"message":";Exception initializing page context;","logger_name":"org.apache.jasper.runtime.JspFactoryImpl","thread_name":"http-bio-0.0.0.0-8081-exec-198","level":"ERROR","level_value":40000,"stack_trace":"java.lang.NoClassDefFoundError: javax/el/StaticFieldELResolver\n\tat org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:172)\n\tat org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:123)\n\tat org.apache.jsp.errors._404_002dnot_002dfound_jsp._jspService(_404_002dnot_002dfound_jsp.java:38)\n\tat org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\tat org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)\n\tat org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)\n\tat org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:731)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat collective.config.startup.DamFilter.doFilter(DamFilter.java:270)\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)\n\tat org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)\n\tat org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:488)\n\tat org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)\n\tat org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)\n\tat org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:476)\n\tat org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:345)\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:210)\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)\n\tat org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)\n\tat org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)\n\tat org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n\tat java.lang.Thread.run(Thread.java:744)\nCaused by: java.lang.ClassNotFoundException: javax.el.StaticFieldELResolver\n\tat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)\n\tat org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)\n\t... 33 common frames omitted\n","customer":"foobaz"}
|
||||
EOF
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-I ${test_dir} \
|
||||
|
Loading…
Reference in New Issue
Block a user