Redirect stdout and stderr to a String
.
There are other packages like this. Some have more features. I like this interface.
See docstrings for stdout_string, with_redirect, redirect_string
.
The simplest, easiest function is stdout_string
.
str = stdout_string() do
print("hi")
end
The function above, stdout_string
is a wrapper around the following, more general function.
julia> res = redirect_string() do
print(stdout, "hi out")
print(stderr, "hi err")
return 1
end
(result = 1, stdout = "hi out", stderr = "hi err")