Speedily search and sort many syslog files by datetime.
Super Speedy Syslog Searcher (s4) is a command-line tool to search
and sort syslog files within compressed files (.gz
, .xz
) and
archives (.tar
, .zip
).
The first goal of s4 is speedy searching and printing.
super_speedy_syslog_searcher
lang-text
cargo install super_speedy_syslog_searcher
s4
For example, print all the syslog lines in syslog files under /var/log/
lang-text
s4 /var/log
Print only the syslog lines since yesterday
lang-text
s4 /var/log -a $(date -d "yesterday" '+%Y-%m-%d')
Print only the syslog lines that occurred two days ago
lang-text
s4 /var/log -a $(date -d "2 days ago" '+%Y-%m-%d') -b $(date -d "1 days ago" '+%Y-%m-%d')
Print only the syslog lines that occurred two days ago during the noon hour
lang-text
s4 /var/log -a $(date -d "2 days ago 12:00" '+%Y-%m-%dT%H:%M:%S') -b $(date -d "2 days ago 13:00" '+%Y-%m-%dT%H:%M:%S')
Print only the syslog lines that occurred two days ago during the noon hour in Bengaluru, India (timezone offset +05:30) and prepended with equivalent UTC datetime.
lang-text
s4 /var/log -u -a "$(date -d "2 days ago 12:00" '+%Y-%m-%dT%H:%M:%S') +05:30" -b "$(date -d "2 days ago 13:00" '+%Y-%m-%dT%H:%M:%S') +05:30"
--help
```lang-text Super Speedy Syslog Searcher will search syslog files and sort entries by datetime. DateTime filters may be passed to narrow the search. It aims to be very fast.
USAGE:
s4 [OPTIONS]
ARGS:
OPTIONS:
-a, --dt-after
DateTime Filter patterns may be: "%Y%m%dT%H%M%S" "%Y%m%dT%H%M%S%z" "%Y-%m-%d %H:%M:%S" "%Y-%m-%d %H:%M:%S %z" "%Y-%m-%dT%H:%M:%S" "%Y-%m-%dT%H:%M:%S %z" "%Y/%m/%d %H:%M:%S" "%Y/%m/%d %H:%M:%S %z" "%Y%m%d" "%Y%m%d %z" "+%s"
Without a timezone offset (%z or %Z), the Datetime Filter is presumed to be the system timezone. Pattern "+%s" is Unix epoch timestamp in seconds with a preceding "+". Ambiguous timezones will be rejected, e.g. "SST". Prepended datetime, -u or -l, is printed in format "%Y%m%dT%H%M%S%.6f %z:". DateTime formatting is described at https://docs.rs/chrono/latest/chrono/format/strftime/
DateTimes supported are only of the Gregorian calendar. DateTimes supported language is English. ```
./logs/
)grep
and sort
(see ./tools/compare-grep-sort.sh
).gz
files (multiple "streams")
(TODO describe problem).xz
files (chooses first file found)
(TODO describe problem).tar
file within another .tar
file will not be processed, a .gz
file within a .tar
file will not be processed, etcetera..xz
files are read into memory during the initial open
(see 607a23c00aff0d9b34fb3d678bdfd5c14290582d)