| set_msg_sink | R Documentation |
When set, msg(), msg0(), msgstart(), and msgdone() forward their
structured output through sink instead of writing to the R console. Used
by rtemis.server to capture training-time messages and forward them over a
WebSocket connection. Pass NULL to restore default console output.
set_msg_sink(sink)
sink |
Function or |
The sink function is called once per message with a single argument: a list with fields
text: character. The formatted message body (no datetime prefix).
caller: character or NA. Calling function as identified by
format_caller().
ts: character. Formatted timestamp ("%Y-%m-%d %H:%M:%S").
level: character. One of "info" (msg/msg0), "start"
(msgstart), "done" (msgdone), or "progress"
(progress_begin() / progress_update() / progress_end()).
Producers may include additional fields in the list, which sinks should
ignore when not understood. In particular, the progress API in this package
and rtemis's training observability
emit execution-graph node events through the sink with these extra fields:
node_id: character. Unique id of the execution-graph node.
parent_id: character or NA. Parent node id (for nesting).
kind: character. Node kind (e.g. "tune", "grid_cell", "train_alg").
status: character. "start", "update", "done", "error", or
"aborted".
current, total: integer or NA. Progress counters.
label: character. Display label without the counts (e.g. "Tuning").
text is the label and counts already composed for display; a sink that
renders its own layout wants this instead of parsing them apart.
These are additive; sinks that only read the base fields keep working.
Progress events fire regardless of verbosity (verbosity gates only the
console renderer), and "update" events are throttled via
getOption("rtemis.progress_throttle") - see progress_begin().
When a sink is set, the console output path is skipped for affected
calls. Errors thrown by the sink propagate to the caller of msg().
Previous sink (function or NULL), invisibly.
EDG
get_msg_sink(), with_msg_sink().
captured <- list()
set_msg_sink(function(m) captured[[length(captured) + 1L]] <<- m)
# msg("hello world") # would append to `captured`
set_msg_sink(NULL) # restore console output
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.