# A pass-through option for IOCapture

**URL:** https://discourse.julialang.org/t/a-pass-through-option-for-iocapture/108642
**Category:** Internals & Design
**Tags:** question, io
**Created:** [January 10, 2024, 8:03pm UTC](https://discourse.julialang.org/t/a-pass-through-option-for-iocapture/108642 "2024-01-10T20:03:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [January 10, 2024, 11:03pm UTC](https://discourse.julialang.org/t/a-pass-through-option-for-iocapture/108642/2 "2024-01-10T23:03:20Z")

</div>

I came up with the start of a possible implementation at [Allow pass-through of output by goerz · Pull Request #20 · JuliaDocs/IOCapture.jl · GitHub](https://github.com/JuliaDocs/IOCapture.jl/pull/20/files)

The core of it is this snippet:

```julia
output = IOBuffer()
temp = IOBuffer()
buffer_redirect_task = @async begin
    write(temp, pipe)
    temp_data = take!(temp)
    write(output, temp_data)
    write(default_stdout, temp_data)
end

```

See also my comment at [Add a `tee` option · Issue #19 · JuliaDocs/IOCapture.jl · GitHub](https://github.com/JuliaDocs/IOCapture.jl/issues/19#issuecomment-1885879370)

If there’s any low-level IO expert who could weigh in on whether this is a sane approach, please leave a comment on the issue or PR.

* * *

I also played around a little with the `Tee` struct from [Write to file and stdout - #3 by Tamas\_Papp](https://discourse.julialang.org/t/write-to-file-and-stdout/35042/3), but it doesn’t seem like `redirect_stdout` can be called with a `Tee` object. If someone knows how to define the appropriate method of `redirect_stdout` to make that work, that would still be a possible alternative.

---

_[View the full topic](https://discourse.julialang.org/t/a-pass-through-option-for-iocapture/108642)._
