Hi Robert,

If you are doing this in a publicly-released package, I would suggest to
make very clear to your users that this is happening and either provide a
way to disable redirection, or send the captured output to a log instead.

The functionality is available via `redirect_output`:
http://julia.readthedocs.org/en/latest/stdlib/base/#Base.redirect_stdout

A minimal example:
```
realout = STDOUT             # grab the old output stream
(rd,wr) = redirect_stdout()   # get redirect handles

@async while true
  readline(rd)                      # effectively /dev/null
end

println("Hello into the vacuum")  # should not be displayed
println(realout, "My output")       # you need to specifically write to the
old stream handle to get visible output
```

(I thought that perhaps the reader task might be unnecessary, but in a
quick test - on Windows - it seems that overflowing the buffer will
deadlock the process).


On Sat, Dec 27, 2014 at 12:25 AM, Robert Gates <[email protected]>
wrote:

> Dear Julia Users,
>
> I would like to silence the output of packages, but am having trouble
> doing so. This applies to package-generated info() messages occuring due to
> "using" calls as well as to the output of external programs, e.g. a solver.
> Basically I'd like to redirect everything except my own specific print-outs
> to /dev/null.
>
> Any way to accomplish this?
>
> Best regards, Robert

Reply via email to