Commit 9c8da27f authored by Kirill Smelkov's avatar Kirill Smelkov

amari.xlog: Flush each emitted line

xlog logging is kind of slow - usually it comes once per several seconds
or once per minute. And without flushing many entries can remain sitting
up in the file buffer in userspace without being conveyed to OS kernel.
Which is not very convenient because in such situation we cannot make good
use of tools like `tail -f`.

Since flushing is relatively cheap operation - it is just one write
syscall - let's do it after every emitted line. The write syscall does
not force data to be synced to disk, so it should not slow things down,
but make it convenient to have latest logs right away in the filesystem
view.
parent 8f94b47d
...@@ -126,7 +126,7 @@ class _XLogger: ...@@ -126,7 +126,7 @@ class _XLogger:
# emit saves line to the log. # emit saves line to the log.
def emit(xl, line): def emit(xl, line):
assert '\n' not in line, line assert '\n' not in line, line
print(line) print(line, flush=True)
# jemit emits line corresponding to event to the log. # jemit emits line corresponding to event to the log.
def jemit(xl, event, args_dict): def jemit(xl, event, args_dict):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment