You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger = basic_config("info")
add_handler(logger, DefaultHandler("temp.log"), "file-log")
info(logger, "some message")
out = STDOUT
err = STDERR
redirect_stdout(logger.handlers["file-log"].io)
redirect_stderr(logger.handlers["file-log"].io)
# run some calls to c libs which produce stuff to stdout (the stuff I want to capture in logfile)
remove_handler(logger, "file-log")
redirect_stdout(out)
redirect_stderr(err)
Messages are periodically flushed to temp.log, (asserted by tailfing it), however last lines are lost??
I tried flush(logger.handlers["file-log"].io) and info(solver_logger, "Finished!") just before the handler is removed to force it to flush the buffer, to no avail...
btw. is there a way to decrease time between flushes??
The text was updated successfully, but these errors were encountered:
ok, so I figured it out: it's a matter of redirect_std|out|err:
Just before redirect_stdout(out) You need to call Base.Libc.flush_cstdio() to flush all C-buffers;
Hmmm, that does seem like pretty awkward behaviour. Given that this appears to be more of a problem with base julia, it might be worth opening an issue here, or modifying the redirect_* methods to include the call to Base.Libc.flush_cstdio() and opening a PR.
I have the following usecase:
Messages are periodically flushed to
temp.log
, (asserted bytailf
ing it), however last lines are lost??I tried
flush(logger.handlers["file-log"].io)
andinfo(solver_logger, "Finished!")
just before the handler is removed to force it to flush the buffer, to no avail...btw. is there a way to decrease time between flushes??
The text was updated successfully, but these errors were encountered: