I considered this but the information is not printed on every iteration (it depends on some conditionals elsewhere in the loop and there is more than one message). Also, I would like the printed output to go to a log file and for the message to remain on screen instead of being replaced when the progress bar is updated.
A bit of carriage-return trickery and filling your terminal with spaces via rpad() is probably the easiest way of doing this yourself. Using displaysize() to get the width of your terminal is needed unless there is another way to query how wide the progress meter is. (I haven’t used ProgressMeter.jl myself.)
prog = Progress(10)
for i in 1:10
if i == 5
println(rpad("\rvalue: $(i^2) this is a message",
displaysize(stdout)[2]))
end
sleep(0.1)
next!(prog)
end
I guess if this output is a common desire, submitting a feature request issue to ProgressMeter.jl or even submitting a PR would be welcome.
This works quite well except that the carriage return \r is written to the log file. Also I needed to make the progress bar slightly narrower because the logging prefix requires some space (I’m using the Memento package).
I wrapped the logging macro in a function to make it easier to use in multiple places: