[tailer] set the mtime on the synced file

pull/884/head
Timothy Stack 3 years ago
parent 22ad9f23a9
commit 9138251355

@ -1,6 +1,6 @@
# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sun Jun 13 22:52:26 PDT 2021
# from AX_AM_MACROS_STATIC on Sun Jun 13 23:05:52 PDT 2021
# Code coverage

@ -21,6 +21,9 @@ Install from the [Snap Store](https://snapcraft.io/lnav):
## MacOS
<!-- markdown-link-check-disable-next-line -->
Download a [statically linked 64-bit binary](https://github.com/tstack/lnav/releases/download/v{{site.version}}/lnav-0.9.0a-os-x.zip)
Install using [Homebrew](https://formulae.brew.sh/formula/lnav):
```shell

@ -1,6 +1,7 @@
---
layout: page
title: Features
permalink: /features
---
* TOC

@ -1,5 +1,6 @@
---
title: ChangeBlog
layout: home
permalink: /blog/
---

@ -35,6 +35,8 @@ plugins:
- jekyll-feed
- jekyll-redirect-from
show_excerpts: true
exclude:
- source

@ -2,6 +2,7 @@
layout: post
title: "Support for JSON-encoded logs in v0.6.1"
date: 2013-09-10 00:00:00
excerpt: Turning JSON barf into something readable.
---
Making logs easily digestible by machines is becoming a concern as tools like

@ -2,6 +2,7 @@
layout: post
title: "Four years on GitHub"
date: 2013-09-13 00:00:00
excerpt: Still going strong!
---
The [first commit](https://github.com/tstack/lnav/commit/b4ec432515e95e86ec9d711833b8cb34d0912546)

@ -2,6 +2,7 @@
layout: post
title: "Competing with 'tail -f'"
date: 2013-09-10 00:00:00
excerpt: The standard utilities are tough competition.
---
Probably the toughest competition for lnav is the standard Unix utilities like

@ -2,6 +2,7 @@
layout: post
title: "Changes To The Scrollbar"
date: 2014-02-22 00:00:00
excerpt: Packing more information into the right scrollbar.
---
I've made some changes to the scrollbar that is shown on the right side of the

@ -0,0 +1,23 @@
---
layout: post
title: Added "lo-fi" mode
excerpt: An alternative way to copy displayed text.
---
*(This change is in v0.7.2+)*
Copying text to the clipboard can be done by marking lines with the
[bookmark hotkeys](https://docs.lnav.org/en/latest/hotkeys.html#bookmarks),
like `m`, and then pressing `c`. Commands that write to a file,
like [`:write-csv-to`](https://docs.lnav.org/en/latest/commands.html#write-csv-to-path)
accept `/dev/clipboard` as a way to write to the clipboard. However, if the
native clipboard isn't supported, or you're on an SSH connection, you can
now switch to "lo-fi" mode. In "lo-fi" mode, lnav drops out of the curses
display and prints the raw text to the terminal. You can switch to "lo-fi"
mode in a view by pressing `CTRL-L`. For commands, you can use a dash `-`
to switch to "lo-fi" and print to standard out.
<script id="asciicast-fH4cdgugIJVcPQnSwCmTdaA7f"
src="https://asciinema.org/a/fH4cdgugIJVcPQnSwCmTdaA7f.js"
async>
</script>

@ -2,6 +2,7 @@
layout: post
title: "Pretty-print view in v0.7.3"
date: 2015-04-11 00:00:00
excerpt: Automatically reformat structured data with "SHIFT+P".
---
I wanted to call out the pretty-print feature in the latest release of lnav.

@ -0,0 +1,16 @@
---
layout: post
title: "Reveal log message source file paths by pressing left-arrow"
excerpt: Find out where log messages are coming from.
---
*(This change is in v0.8.4+)*
If you want to know which file log messages are coming from, you can press the
left-arrow to reveal the unique name and then press it again to reveal the
full path.
<script id="asciicast-ATHHpQiHVaTVxVRkhCv4ED7wT"
src="https://asciinema.org/a/ATHHpQiHVaTVxVRkhCv4ED7wT.js"
async>
</script>

@ -0,0 +1,22 @@
---
layout: post
title: "Support for tagging and commenting on log messages"
excerpt: Annotate log messages with your thoughts.
---
*(This change is in v0.8.4+)*
If you have been wanting to add notes to log messages you might be interested
in, the new [`:comment`](https://docs.lnav.org/en/latest/commands.html#comment-text)
and [`:tag`](https://docs.lnav.org/en/latest/commands.html#tag-tag) commands.
These commands add a comment or tag(s) to the top message in the log view.
The comments and tags are saved in the session, so they will be restored
automatically when the file is reopened. These annotations can be searched
for using the regular search prompt and can be accessed in the
[log tables](https://docs.lnav.org/en/latest/sqlext.html#log-tables) using the
`log_tags` and `log_comment` columns.
<script id="asciicast-yRTcQd2VMv3QZVs5597OyAAxI"
src="https://asciinema.org/a/yRTcQd2VMv3QZVs5597OyAAxI.js"
async>
</script>

@ -0,0 +1,35 @@
---
layout: post
title: "Visual filter editor"
excerpt: A friendlier way to interact with filters.
---
*(This change is in v0.8.5+)*
A visual filter editor has been added to make it easier to create, edit,
enable, disable, and delete filters. In the log or text views, pressing `TAB`
will open the filter editor panel. While the panel is in focus, the following
hotkeys can be used:
- `i` - Create an IN filter that will only show lines that match the given
regular expression.
- `o` - Create an OUT filter that will hide lines that match the given regular
expression.
- `Space` - Toggle the filter between being enabled and disabled.
- `Enter` - Edit the selected filter.
- `Shift+D` - Delete the filter.
- `t` - Switch a filter from an IN to an OUT or vice-versa.
- `f` - Globally enable or disable filtering.
When editing a filter, the main view will highlight lines that portion of the
lines that match the given regular expression:
- Lines that match an OUT filter are highlighted with red;
- Lines that match an IN filter are highlighted with green.
You can also press `TAB` to complete words that are visible in the main view.
<script id="asciicast-tcHeLbqVImRVcxWTYIrm3v6bw"
src="https://asciinema.org/a/tcHeLbqVImRVcxWTYIrm3v6bw.js"
async>
</script>

@ -819,59 +819,77 @@ readline_context::command_map_t lnav_commands;
static void usage()
{
const char *usage_msg =
"usage: %s [options] [logfile1 logfile2 ...]\n"
"\n"
"A curses-based log file viewer that indexes log messages by type\n"
"and time to make it easier to navigate through files quickly.\n"
"\n"
"Key bindings:\n"
" ? View/leave the online help text.\n"
" q Quit the program.\n"
"\n"
"Options:\n"
" -h Print this message, then exit.\n"
" -H Display the internal help text.\n"
" -I path An additional configuration directory.\n"
" -i Install the given format files and exit. Pass 'extra'\n"
" to install the default set of third-party formats.\n"
" -u Update formats installed from git repositories.\n"
" -C Check configuration and then exit.\n"
" -d path Write debug messages to the given file.\n"
" -V Print version information.\n"
"\n"
" -a Load all of the most recent log file types.\n"
" -r Recursively load files from the given directory hierarchies.\n"
" -R Load older rotated log files as well.\n"
" -t Prepend timestamps to the lines of data being read in\n"
" on the standard input.\n"
" -w file Write the contents of the standard input to this file.\n"
"\n"
" -c cmd Execute a command after the files have been loaded.\n"
" -f path Execute the commands in the given file.\n"
" -n Run without the curses UI. (headless mode)\n"
" -N Do not open the default syslog file if no files are given\n"
" -q Do not print the log messages after executing all\n"
" of the commands.\n"
"\n"
"Optional arguments:\n"
" logfile1 The log files or directories to view. If a\n"
" directory is given, all of the files in the\n"
" directory will be loaded.\n"
"\n"
"Examples:\n"
" To load and follow the syslog file:\n"
" $ lnav\n"
"\n"
" To load all of the files in /var/log:\n"
" $ lnav /var/log\n"
"\n"
" To watch the output of make with timestamps prepended:\n"
" $ make 2>&1 | lnav -t\n"
"\n"
"Version: " VCS_PACKAGE_STRING "\n";
fprintf(stderr, usage_msg, lnav_data.ld_program_name);
const char *usage_msg = R"(usage: %s [options] [logfile1 logfile2 ...]
A curses-based log file viewer that indexes log messages by type
and time to make it easier to navigate through files quickly.
Key bindings:
? View/leave the online help text.
q Quit the program.
Options:
-h Print this message, then exit.
-H Display the internal help text.
-I path An additional configuration directory.
-i Install the given format files and exit. Pass 'extra'
to install the default set of third-party formats.
-u Update formats installed from git repositories.
-C Check configuration and then exit.
-d path Write debug messages to the given file.
-V Print version information.
-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.
-t Prepend timestamps to the lines of data being read in
on the standard input.
-w file Write the contents of the standard input to this file.
-c cmd Execute a command after the files have been loaded.
-f path Execute the commands in the given file.
-n Run without the curses UI. (headless mode)
-N Do not open the default syslog file if no files are given.
-q Do not print the log messages after executing all
of the commands.
Optional arguments:
logfileN The log files, directories, or remote paths to view.
If a directory is given, all of the files in the
directory will be loaded.
Examples:
To load and follow the syslog file:
$ lnav
To load all of the files in /var/log:
$ lnav /var/log
To watch the output of make with timestamps prepended:
$ make 2>&1 | lnav -t
Paths:
Configuration, session, and format files are stored in:
%s
Local copies of remote files and files extracted from
archives are stored in:
%s
Documentation: https://docs.lnav.org
Contact:
https://github.com/tstack/lnav/discussions
%s
Version: %s
)";
fprintf(stderr,
usage_msg,
lnav_data.ld_program_name,
lnav::paths::dotlnav().c_str(),
lnav::paths::workdir().c_str(),
PACKAGE_BUGREPORT,
VCS_PACKAGE_STRING);
}
static void clear_last_user_mark(listview_curses *lv)

@ -744,6 +744,10 @@ void tailer::looper::host_tailer::loop_body()
pwrite(fd,
ptb.ptb_bits.data(), ptb.ptb_bits.size(),
ptb.ptb_offset);
auto mtime = ghc::filesystem::file_time_type{
std::chrono::seconds{ptb.ptb_mtime}};
// XXX This isn't atomic with the write...
ghc::filesystem::last_write_time(local_path, mtime);
}
return std::move(this->ht_state);
},

@ -542,6 +542,7 @@ int poll_paths(struct list *path_list, struct client_path_state *root_cps)
TPT_OFFER_BLOCK,
TPPT_STRING, root_cps->cps_path,
TPPT_STRING, curr->cps_path,
TPPT_INT64, (int64_t) st.st_mtime,
TPPT_INT64, file_offset,
TPPT_INT64, bytes_read,
TPPT_HASH, hash,
@ -556,6 +557,7 @@ int poll_paths(struct list *path_list, struct client_path_state *root_cps)
TPT_TAIL_BLOCK,
TPPT_STRING, root_cps->cps_path,
TPPT_STRING, curr->cps_path,
TPPT_INT64, (int64_t) st.st_mtime,
TPPT_INT64, curr->cps_client_file_offset,
TPPT_BITS, bytes_read, buffer,
TPPT_DONE);

@ -85,6 +85,7 @@ Result<packet, std::string> read_packet(int fd)
TRY(read_payloads_into(fd,
pob.pob_root_path,
pob.pob_path,
pob.pob_mtime,
pob.pob_offset,
pob.pob_length,
pob.pob_hash));
@ -96,6 +97,7 @@ Result<packet, std::string> read_packet(int fd)
TRY(read_payloads_into(fd,
ptb.ptb_root_path,
ptb.ptb_path,
ptb.ptb_mtime,
ptb.ptb_offset,
ptb.ptb_bits));
return Ok(packet{ptb});

@ -71,6 +71,7 @@ struct packet_log {
struct packet_offer_block {
std::string pob_root_path;
std::string pob_path;
int64_t pob_mtime;
int64_t pob_offset;
int64_t pob_length;
hash_frag pob_hash;
@ -79,6 +80,7 @@ struct packet_offer_block {
struct packet_tail_block {
std::string ptb_root_path;
std::string ptb_path;
int64_t ptb_mtime;
int64_t ptb_offset;
std::vector<uint8_t> ptb_bits;
};

Loading…
Cancel
Save