How to flush stdout


#1

I have a Julia script that has a bunch of println statements interleaved some heavy computation functions. I typically run such scripts, redirect to a file, and then do tail -f to see what’s going on. It appears that the output is buffered. I tried to make it flush but it doesn’t work… What’s the right way to do this?

My logging function:

log(x...) = println(now(), " ", join(x, " ")...); flush(STDOUT)

#3

This definition doesn’t do what you probably want it to do. It’s equivalent to this:

log(x...) = println(now(), " ", join(x, " ")...)

flush(STDOUT)

You probably want this:

function log(x...)
    println(now(), " ", join(x, " ")...)
    flush(STDOUT)
end

#4

Thanks for correcting my sloppiness :slight_smile: