StreamToString.jl

Redirect stdout and stderr to a string in Julia
Author jlapeyre
Popularity
8 Stars
Updated Last
3 Months Ago
Started In
April 2022

StreamToString

Build Status Coverage Aqua QA JET QA

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.

stdout_string

str = stdout_string() do
    print("hi")
end

redirect_string

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")

Other packages