daroczig/logger

Async logger fails when warnings thrown upon package load

charliebone opened this issue · 1 comments

The async logger fails to work if loading one of the required packages (logger or txtq) produces a warning.

In my case, I am running one patch version behind the latest for my major/minor version (4.2.2, vs 4.2.3 as the latest). When loading logger, I did get the obligatory warning:

require(logger)
Loading required package: logger
Warning message:
packageloggerwas built under R version 4.2.3 

The issue is that when the async logger sources the script that calls require for logger and txtq, these warnings are printed in the spawned callr session and then the async logger process handle reads these as errors, causing the logger to fail:

log_appender(appender_async(appender_file(tempfile())))
log_info("test")
Error in appender(res$record) : 
  FATAL: Async writer failed with "Warning messages:

Obviously this can be fixed by upgrading to the latest patch version of R (which I have done), but the error message received isn't entirely clear this is the issue and confused me for a hot minute before I realized what was going on.

The only suggestion I have to fix is to wrap the require() calls in the "load-packages-in-background-process.R" script with suppressWarnings(). Perhaps there could be some undesirable consequences from doing this, but I don't know what possible warnings besides version issues could be thrown in the fresh vanilla callr session spawned for the async process.

Thoughts?

Session info

``` r R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] logger_0.3.0 txtq_0.2.4

loaded via a namespace (and not attached):
[1] processx_3.8.0 compiler_4.2.2 backports_1.4.1 R6_2.5.1 base64url_1.4 tools_4.2.2 glue_1.6.2 rstudioapi_0.14
[9] callr_3.7.3 filelock_1.0.3 ps_1.7.2

</details>

This is now fixed thanks to #215 (moving away from the txtq queue-based approach using mirai).