Module: Aspera::Sync::LogParser
- Defined in:
- lib/aspera/sync/log_parser.rb
Overview
Extract the notable events from async (Aspera Sync) log files: file conflicts and errors,
unsupported file-system events, session lifecycle (start, stop, idle), and ERR-level lines.
The bulk of the log (synchronized files, transfers, periodic statistics) is skipped.
A line looks like: 2026-11-24 20:51:01.275 [d4fc-18637435] LOG [Sync_reporter] SYNC FILE STOP ... status=CONFLICT
Constant Summary collapse
- LINE =
One log line: timestamp, process id, level, optional bracketed component, message
/\A(?<time>\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d+) \[[^\]]+\] (?<level>[A-Z]+) (?:\[(?<component>[^\]]+)\] )?(?<message>.*)\z/- FILE_STATUS_OK =
statusofSYNC FILE STOPthat means the file is synchronized, so not notable (alsoSYNCHRONIZED(exs): already present) 'SYNCHRONIZED'- SESSION_EVENTS =
SYNC SESSION <event>kept (lifecycle); the others (STATS, PROG, READY, NEW, SCAN, PARAMETERS) are skipped %w[START STOP IDLE].freeze
- SESSION_EVENT =
/\ASYNC SESSION (#{SESSION_EVENTS.join('|')})\b/- NOTABLE_LEVELS =
Log levels that are always notable
%w[ERR ERROR FATAL].freeze
- UNSUPPORTED_EVENT =
Text of the file-system watcher error (async
Monitor_fsevents.cpp) 'Unsupported file system event'- DETAIL_MAX =
Longest
detailkept for display: the raw message of anERRline can be very long 200- ASYNC_FILE =
Names of the
asynclog files in a folder: current file and its rotations /\Aasync(?:\.\d+)?\.log(?:\.gz)?\z/- SYSLOG_FILES =
Linux and Unix:
asynclogs to syslog (one of these files, depending on the syslog configuration) %w[/var/log/aspera.log /var/log/messages /var/log/syslog].freeze
- FIELDS =
Default fields shown for the events
%w[time level session kind path status detail].freeze
- FIELD_RE =
Compiled regular expression for each
key=...read from a message (built once per key) Hash.new { |cache, key| cache[key] = /\b#{Regexp.escape(key)}=(?:"([^"]*)"|(\S+))/ }
Class Method Summary collapse
-
.default_location_hint ⇒ String
Human description of the default location, for an error message.
-
.default_log_paths ⇒ Array<String>
The
asynclog files at the default location of the local host (existing only). -
.notable_events(paths, readable: nil) ⇒ Array<Hash>
Notable events, oldest first (across files, by timestamp).
Class Method Details
.default_location_hint ⇒ String
Returns human description of the default location, for an error message.
64 65 66 67 68 69 70 |
# File 'lib/aspera/sync/log_parser.rb', line 64 def default_location_hint case Environment.instance.os when Environment::OS_MACOS then File.join(Dir.home, 'Library', 'Logs', 'Aspera', 'async.log') when Environment::OS_WINDOWS then 'the working folder of async' else SYSLOG_FILES.join(', ') end end |
.default_log_paths ⇒ Array<String>
Returns the async log files at the default location of the local host (existing only).
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/aspera/sync/log_parser.rb', line 51 def default_log_paths case Environment.instance.os when Environment::OS_MACOS [File.join(Dir.home, 'Library', 'Logs', 'Aspera', 'async.log')].select { |file| File.file?(file) } when Environment::OS_WINDOWS # `async` logs to its working folder on Windows: no fixed default location [] else SYSLOG_FILES.select { |file| File.file?(file) } end end |
.notable_events(paths, readable: nil) ⇒ Array<Hash>
Returns notable events, oldest first (across files, by timestamp).
44 45 46 47 48 |
# File 'lib/aspera/sync/log_parser.rb', line 44 def notable_events(paths, readable: nil) paths.flat_map { |path| path_files(path, readable) } .flat_map { |file| file_events(file) } .sort_by { |event| event['time'] } end |