I would like to print the output of a @time
in a production environment. To avoid cluttering up the logs, I try to keep a bit of discipline with the logging so everything should use a log level. Now my question is, how can I print @time
with a info log-level? The following doesn’t work:
julia> @info @time sum([1, 2])
0.000001 seconds (1 allocation: 80 bytes)
[ Info: 3
because @time
prints to stdout
. At the same time, capture_stdout
requires me to write to a file (https://github.com/JuliaLang/julia/issues/12711)?
EDIT: There is IOCapture.jl
. It is a bit unfortunate to be required to install that. Maybe there is another workaround for this case.