Using trace in pengine server, any way to send the output trace to the client?

If I have a pengine server containing rules and facts. I can send a query like get_safe_foods(\"jane_smith@nqminds.com\", SafeFoods) to the pengine server and get the resulting safe foods in json format like:

{
      "SafeFoods": [
        "Vegetable Stir Fry",
        "Spaghetti Bolognese"
    ]
}

I want to use the trace command (or similar) to return the reasoning logic behind this answer to the client.

I can mark the predicates as safe like so:

:- module(mymodule,
[
    traceOn/0,
    traceOff/0,
    leashAlias/1
]
).


traceOn() :- 
    trace.

traceOff() :-
    notrace.

leashAlias(Arg) :-
    leash(Arg).

:- multifile
sandbox:safe_primitive/1.

sandbox:safe_primitive(mymodule:traceOn()).
sandbox:safe_primitive(mymodule:traceOff()).
sandbox:safe_primitive(mymodule:leashAlias(_)).

And run them by sending this command from the client:

mymodule:leashAlias(-all), mymodule:traceOn(), get_safe_foods(\"jane_smith@nqminds.com\", SafeFoods), mymodule:traceOff()

However the trace is displayed on the server side with no visibility to the client. Is there a way to return the trace or similar to the client?