Update variable in logged message without printing a new line?

For a quick and dirty alternative you could use an ANSI escape code to move the cursor back 1000 positions after printing the string (we are at the start of the line again).

function testlog()
    i = 1
    for n in 1:5
        print("Processing file number $i\u001b[1000D")
        sleep(0.3)  # simulate some work
        i += 1
    end
end

testlog()
3 Likes