How to use Malt.jl and IOCapture.jl for evaluating expressions

I would like to use Malt.jl to evaluate expressions in a workspace separate from the main thread running Julia. So far I have not been able to find a way to use Malt.jl and capture with IOCapture the different outputs of the code running in a Malt worker (output values, console outputs and errors).
For Example

import Malt
worker = Malt.Worker.();
expr = :(print("Hi");1+1;)
Malt.remote_eval_fetch(worker,:($expr)) 

How to capture from the last line of code what is painted on the console and the result of the operation. Also, if it is a plot that is attempted to be executed, how to capture the output of the plot?

I suppose this will do?

using IOCapture, Malt, Plots
worker=Malt.Worker()
Malt.remote_eval(worker, :(using IOCapture, Plots))
results=Malt.remote_eval_feth(worker, quote
    IOCapture.capture() do 
        println("Creating plot")
        return scatter([1,2,3], [4,5,6])
    end
end)

julia> results.output
"Begin creating plot\n"

julia> results.value
# returns the plot

Your code is likely to be long, so it’d be better to use the quote block.
Wrap your code inside IOCapture.capture and make sure you return the plot in the end, and I’m pretty sure you’ll get what you want.

Thank you so much, works well.