You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to be able to route to a file all of the messages (diagnostics, etc.) that $sample() prints to the console.
Possible interface options
There are two obvious options for how to expose this:
Have a new argument (something like messages_file or messages_out_path) that take a file path and sends all output to that file.
Change the show_messages argument to accept a boolean or a file path:
TRUE prints messages to console
FALSE prints no messages
path sends messages to file instead of console
The second option has the appeal of not adding another (fairly specific) argument, though it does make this argument take mixed types (logical or character). This is a little messy, but not unprecedented (for example, callr does it here).
This second option would also mean that the user could either print to console or save to file, but not both. Looking at the implementation in processx, we may be stuck with this behavior regardless, in which case I'd prefer this second solution. However, I think ideally the user could choose console, file, or both.
Additional context
This originally came out of discussion in #424 and @rok-cesnovar suggested splitting this into its own issue.
There are some possible workarounds, which I think makes this not super high priority. For example, @wlandauuses withr for this purpose in stantargets. It's also possible to call $sample() within either callr::r() or callr::r_bg() and use the show, stdout, and stderr args to accomplish any desired combo of logging to the console and/or a file:
res<-callr::r(
{function() stanmod$sample(...)},
args=list(stanmod),
show=TRUE, # controls printing to consolestdout="/some/log/file", # sends stdout to filestderr="2>&1"# interleaves stderr with stdout
)
The text was updated successfully, but these errors were encountered:
Summary
I would like to be able to route to a file all of the messages (diagnostics, etc.) that
$sample()
prints to the console.Possible interface options
There are two obvious options for how to expose this:
messages_file
ormessages_out_path
) that take a file path and sends all output to that file.show_messages
argument to accept a boolean or a file path:TRUE
prints messages to consoleFALSE
prints no messagespath
sends messages to file instead of consoleThe second option has the appeal of not adding another (fairly specific) argument, though it does make this argument take mixed types (logical or character). This is a little messy, but not unprecedented (for example,
callr
does it here).This second option would also mean that the user could either print to console or save to file, but not both. Looking at the implementation in
processx
, we may be stuck with this behavior regardless, in which case I'd prefer this second solution. However, I think ideally the user could choose console, file, or both.Additional context
This originally came out of discussion in #424 and @rok-cesnovar suggested splitting this into its own issue.
There are some possible workarounds, which I think makes this not super high priority. For example, @wlandau uses
withr
for this purpose instantargets
. It's also possible to call$sample()
within eithercallr::r()
orcallr::r_bg()
and use theshow
,stdout
, andstderr
args to accomplish any desired combo of logging to the console and/or a file:The text was updated successfully, but these errors were encountered: