mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 08:34:39 +00:00
logging, throw an exception when logfile doesn't look like a clog file, makes it easier to auto-detect clog/plain logs
This commit is contained in:
parent
8df5374a9f
commit
5c6d780f8c
@ -85,6 +85,8 @@ def fetch_clog(input_log):
|
||||
mm = mmap.mmap(fd.fileno(), 0)
|
||||
# unpack clog information struct
|
||||
clog_footer = struct.unpack('iiii', mm[-16:]) # cf_magic, cf_wrap, cf_next, cf_max, cf_lock
|
||||
if mm[-20:-16] != b'CLOG':
|
||||
raise Exception('not a valid clog file')
|
||||
# concat log file into new output stream, start at current wrap position
|
||||
output_stream = StringIO(mm[clog_footer[1]:-20].decode() + mm[:clog_footer[1]].decode())
|
||||
output_stream.seek(0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user