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
{{ message }}
Repository navigation
Capture all R Console output _with_ timestamp? #289
Hi shinytest2 devs,
I feel like I'm missing an option somewhere but I can't seem to find the answer to this question in the help docs or with Google.
I've saved the log object returned by the ShinyDriver$get_logs method and am noticing that while the console messages are included, they don't appear to be timestamped which makes it impossible to determine the relationships evident when messages are in order. Is there some way to have all the console output timestamped in the shinytest2 log?
Currently all R logs are captured from a {processx} object. This is created via callr::r_bg().
If there is a way to capture the time stamp from a processx object, I'd be very happy to pursue it.
Current docs for stderr (and also stdout) within processx:
stderr
What to do with the standard error. Possible values:
NULL: discard it.
A string, redirect it to this file. Note that if you specify a relative path, it will be relative to the current working directory, even if you specify another directory in the wd argument. (See issue 324.)
"|": create a connection for it.
"2>&1": redirect it to the same connection (i.e. pipe or file) as stdout. "2>&1" is a way to keep standard output and error correctly interleaved.
"" (empty string): inherit it from the main R process. If the main R process does not have a standard error stream, e.g. in RGui on Windows, then an error is thrown.
I just realized a workaround with shinyjs for anyone waiting on this - you can create a debug message function with shinyjs::runjs(glue::glue("console.log('{[msg]}')")) to output the debug messages to the JS console which are timestamped in the log
Activity
schloerke commentedon Jan 6, 2023
Currently all R logs are captured from a
{processx}object. This is created viacallr::r_bg().If there is a way to capture the time stamp from a processx object, I'd be very happy to pursue it.
Current docs for
stderr(and alsostdout) withinprocessx:Taking inspiration from https://unix.stackexchange.com/a/26797, I tried changing
"|"to"| ts '[%Y-%m-%d %H:%M:%S]"and it did not work. I have not find a working solution.(This may be a request for
{processx}(which{shinytest2}can then implement.)yogat3ch commentedon Jan 10, 2023
Thanks for digging into this @schloerke! I'll crosspost this on
{processx}schloerke commentedon Jan 10, 2023
🥳 Once in
{callr},{shinytest2}can implement it. Woohoo!yogat3ch commentedon Feb 15, 2023
I just realized a workaround with
shinyjsfor anyone waiting on this - you can create a debug message function withshinyjs::runjs(glue::glue("console.log('{[msg]}')"))to output the debug messages to the JS console which are timestamped in the logAn example function is here