Julia: Having the f () function containing the @printf macro, how can I access the output outside f ()?

In the Julia package, NMF a verboseprovides macro convergence information @printf.

How can I access this output without overwriting the NMFio package ?

To rephrase, having a function f()containing a macro @printf, how can I access the output outside f()?

+4
source share
1 answer

This seems like useful functionality: I would suggest that you ask for a package problem.

However, the following should work as a quick hack:

oldout = STDOUT
(rd,wr) = redirect_stdout()
start_reading(rd)

# call your function here

flush_cstdio()
redirect_stdout(oldout)
close(wr)
s = readall(rd)
close(rd)
s
+4
source

All Articles