Skip to content

Instantly share code, notes, and snippets.

@tcopestake
Created July 4, 2014 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcopestake/3b3c0891d4ca29df9f09 to your computer and use it in GitHub Desktop.
Save tcopestake/3b3c0891d4ca29df9f09 to your computer and use it in GitHub Desktop.
original_stdout = STDOUT
(stdout_read, stdout_write) = redirect_stdout()
redirect_stderr(STDOUT)
logfile = open("G:/Dev/julia-stdout.txt", "a+")
atexit(function ()
close(stdout_write)
close(stdout_read)
close(logfile)
end)
@async begin
while true
stream_data = readavailable(stdout_read)
# Send output to console (via original STDOUT)
write(original_stdout, stream_data)
flush(original_stdout)
# Log to file.
write(logfile, stream_data)
flush(logfile)
#
end
end
r_display = TextDisplay(stdout_write)
pushdisplay(r_display)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment