Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.
Introducing logrx 0.4.0: Enhanced Logging for Your R Programs
The
The team from GSK, Atorus, J&J and Pfzier are excited to announce a mini-release of
Making your first log with logrx
Before we introduce the new features, let’s first do a quick introduction to axecute()
. You can expand the > R File axecuted by logrx and > Log File created from axecute() from logrx folds to see the file as well as the log that is produced.
logrx::axecute("logrx_test_file.R")
R File axecuted by logrx
# Load necessary libraries library(pharmaversesdtm) library(dplyr) # Check if the package is installed if (!requireNamespace("pharmaversesdtm", quietly = TRUE)) { stop("The pharmaversesdtm package is not installed. Please install it first.") } # Load example data data("dm", package = "pharmaversesdtm") # Display a message message("Starting data manipulation using dplyr...") # Execute the manipulation tryCatch({ # Simple dplyr operations # Filter for males and select specific columns filtered_data <- dm %>% filter(RACE == "M") %>% select(STUDYID, USUBJID, AGE, SEX) # Print the first few rows of the filtered data print(filtered_data) # If the dataset is empty after filtering, provide a warning if (nrow(filtered_data) == 0) { warning("The filtered dataset has no data. Please check your filter criteria.") } }, error = function(err) { warning("An error occurred during processing: ", err$message) }) # Display a message indicating completion message("Data manipulation completed.")
Log File created from axecute() from logrx
-------------------------------------------------------------------------------- - logrx Metadata - -------------------------------------------------------------------------------- This log was generated using logrx 0.4.0 logrx package version: 0.4.0 logrx build: RSPM (R 4.4.0) logrx link to repository: https://github.com/pharmaverse/logrx -------------------------------------------------------------------------------- - User and File Information - -------------------------------------------------------------------------------- User: r590548 File Name: logrx_test_file.R File Path: /cloud/project/posts/zzz_DO_NOT_EDIT_logrx_0.4.0... File HashSum: 60930bc7b27a4222f6f8e7e5c9f8192127ec32c2 -------------------------------------------------------------------------------- - Session Information - -------------------------------------------------------------------------------- ─ Session info ─────────────────────────────────────────────────────────────── setting value version R version 4.4.3 (2025-02-28) os Ubuntu 20.04.6 LTS system x86_64, linux-gnu ui X11 language (EN) collate C.UTF-8 ctype C.UTF-8 tz UTC date 2025-05-17 pandoc 3.1.11 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64/ (via rmarkdown) quarto 1.7.29 @ /usr/bin/quarto ─ Packages ─────────────────────────────────────────────────────────────────── package * version date (UTC) lib source bslib 0.9.0 2025-01-30 [1] RSPM (R 4.4.0) cachem 1.1.0 2024-05-16 [1] RSPM (R 4.4.0) cli 3.6.3 2024-06-21 [1] RSPM (R 4.4.0) curl 6.2.0 2025-01-23 [1] RSPM (R 4.4.0) digest 0.6.37 2024-08-19 [1] RSPM (R 4.4.0) downlit 0.4.4 2024-06-10 [1] RSPM (R 4.4.0) dplyr * 1.1.4 2023-11-17 [1] RSPM (R 4.4.0) evaluate 1.0.3 2025-01-10 [1] RSPM (R 4.4.0) fastmap 1.2.0 2024-05-15 [1] RSPM (R 4.4.0) generics 0.1.3 2022-07-05 [1] RSPM (R 4.4.0) glue 1.8.0 2024-09-30 [1] RSPM (R 4.4.0) htmltools 0.5.8.1 2024-04-04 [1] RSPM (R 4.4.0) htmlwidgets 1.6.4 2023-12-06 [1] RSPM (R 4.4.0) httr2 1.1.0 2025-01-18 [1] RSPM (R 4.4.0) jquerylib 0.1.4 2021-04-26 [1] RSPM (R 4.4.0) jsonlite 1.8.9 2024-09-20 [1] RSPM (R 4.4.0) knitr 1.49 2024-11-08 [1] RSPM (R 4.4.0) lifecycle 1.0.4 2023-11-07 [1] RSPM (R 4.4.0) link * 2024.4.0 2024-03-11 [1] RSPM (R 4.4.0) logrx 0.4.0 2025-05-05 [1] RSPM (R 4.4.0) magrittr 2.0.3 2022-03-30 [1] RSPM (R 4.4.0) memoise 2.0.1 2021-11-26 [1] RSPM (R 4.4.0) pharmaversesdtm * 1.2.0 2025-01-23 [1] RSPM (R 4.4.0) pillar 1.10.1 2025-01-07 [1] RSPM (R 4.4.0) pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.4.0) purrr 1.0.4 2025-02-05 [1] RSPM (R 4.4.0) R6 2.6.0 2025-02-12 [1] RSPM (R 4.4.0) rappdirs 0.3.3 2021-01-31 [1] RSPM (R 4.4.0) rlang 1.1.5 2025-01-17 [1] RSPM (R 4.4.0) rmarkdown 2.29 2024-11-04 [1] RSPM (R 4.4.0) rstudioapi 0.17.1 2024-10-22 [1] RSPM (R 4.4.0) sass 0.4.9 2024-03-15 [1] RSPM (R 4.4.0) sessioninfo 1.2.3 2025-02-05 [1] RSPM (R 4.4.0) stringi 1.8.4 2024-05-06 [1] RSPM (R 4.4.0) stringr 1.5.1 2023-11-14 [1] RSPM (R 4.4.0) tibble 3.2.1 2023-03-20 [1] RSPM (R 4.4.0) tidyr 1.3.1 2024-01-24 [1] RSPM (R 4.4.0) tidyselect 1.2.1 2024-03-11 [1] RSPM (R 4.4.0) vctrs 0.6.5 2023-12-01 [1] RSPM (R 4.4.0) withr 3.0.2 2024-10-28 [1] RSPM (R 4.4.0) xfun 0.50 2025-01-07 [1] RSPM (R 4.4.0) xml2 1.3.6 2023-12-04 [1] RSPM (R 4.4.0) yaml 2.3.10 2024-07-26 [1] RSPM (R 4.4.0) [1] /cloud/lib/x86_64-pc-linux-gnu-library/4.4 [2] /opt/R/4.4.3/lib/R/library * ── Packages attached to the search path. ─ External software ────────────────────────────────────────────────────────── setting value cairo 1.16.0 cairoFT pango 1.44.7 png 1.6.37 jpeg 8.0 tiff LIBTIFF, Version 4.1.0 tcl 8.6.10 curl 7.68.0 zlib 1.2.11 bzlib 1.0.8, 13-Jul-2019 xz 5.2.4 deflate PCRE 10.34 2019-11-21 ICU 66.1 TRE TRE 0.8.0 R_fixes (BSD) iconv glibc 2.31 readline 8.0 BLAS /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 lapack /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 lapack_version 3.9.0 ─ Python configuration ─────────────────────────────────────────────────────── Python is not available ────────────────────────────────────────────────────────────────────────────── -------------------------------------------------------------------------------- - Masked Functions - -------------------------------------------------------------------------------- function `plot` from {package:base} by package:graphics function `body<-` from {package:base} by package:methods function `kronecker` from {package:base} by package:methods -------------------------------------------------------------------------------- - Used Package and Functions - -------------------------------------------------------------------------------- {package:base} library, requireNamespace, stop, message, tryCatch, print, nrow, warning {package:dplyr} %>%, filter, select {package:utils} data -------------------------------------------------------------------------------- - Program Run Time Information - -------------------------------------------------------------------------------- Start time: 2025-05-17 16:13:30 UTC End time: 2025-05-17 16:13:30 UTC Run time: 0 seconds -------------------------------------------------------------------------------- - Errors and Warnings - -------------------------------------------------------------------------------- Errors: Warnings: The filtered dataset has no data. Please check your filter criteria. -------------------------------------------------------------------------------- - Messages, Output, and Result - -------------------------------------------------------------------------------- Messages: Attaching package: 'dplyr' The following objects are masked from 'package:stats': filter, lag The following objects are masked from 'package:base': intersect, setdiff, setequal, union Starting data manipulation using dplyr... Data manipulation completed. Output: # A tibble: 0 × 4 # ℹ 4 variables: STUDYID <chr>, USUBJID <chr>, AGE <dbl>, SEX <chr> Result: NULL -------------------------------------------------------------------------------- - Log Output File - -------------------------------------------------------------------------------- Log name: logrx_test_file.log Log path: /cloud/project/posts/zzz_DO_NOT_EDIT_logrx_0.4.0...
It is that easy to make a log for your R program with this lightweight logging package! Also recommend checking out the pharmaverse examples page where a side-by-side comparison is available for 3 R logging packages:
New Features
It is small release, but we feel it packs a big punch!
Enhanced Functionality with axecute()
The latest update introduces the extra_info
parameter in the
Check out this simple example to see how to add some extra info to your log file.
logrx::axecute( file = "logrx_test_file.R", log_name = "logrx_test_file_extra_info1.log", extra_info = list("orange", paste0("green eggs and ham")) )
Here is the relevant section from the log file.
-------------------------------------------------------------------------------- - Extra info - -------------------------------------------------------------------------------- - orange - green eggs and ham
You can unfold this section to see the entire log file.
Log File created from axecute() from logrx with extra_info
-------------------------------------------------------------------------------- - logrx Metadata - -------------------------------------------------------------------------------- This log was generated using logrx 0.4.0 logrx package version: 0.4.0 logrx build: RSPM (R 4.4.0) logrx link to repository: https://github.com/pharmaverse/logrx -------------------------------------------------------------------------------- - User and File Information - -------------------------------------------------------------------------------- User: r590548 File Name: logrx_test_file.R File Path: /cloud/project/posts/zzz_DO_NOT_EDIT_logrx_0.4.0... File HashSum: 60930bc7b27a4222f6f8e7e5c9f8192127ec32c2 -------------------------------------------------------------------------------- - Session Information - -------------------------------------------------------------------------------- ─ Session info ───────────────────────────────────────────────────────────────── setting value version R version 4.4.3 (2025-02-28) os Ubuntu 20.04.6 LTS system x86_64, linux-gnu ui RStudio language (EN) collate C.UTF-8 ctype C.UTF-8 tz UTC date 2025-05-17 rstudio 2024.04.2+764.pro1 Chocolate Cosmos (server) pandoc 3.1.11 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/x86_64/ (via rmarkdown) quarto 1.7.29 @ /usr/bin/quarto ─ Packages ───────────────────────────────────────────────────────────────────── package * version date (UTC) lib source admiraldev * 1.2.0 2025-01-15 [1] RSPM (R 4.4.0) backports 1.5.0 2024-05-23 [1] RSPM (R 4.4.0) bslib 0.9.0 2025-01-30 [1] RSPM (R 4.4.0) cachem 1.1.0 2024-05-16 [1] RSPM (R 4.4.0) checkmate * 2.3.2 2024-07-29 [1] RSPM (R 4.4.0) cli 3.6.3 2024-06-21 [1] RSPM (R 4.4.0) digest 0.6.37 2024-08-19 [1] RSPM (R 4.4.0) dplyr * 1.1.4 2023-11-17 [1] RSPM (R 4.4.0) evaluate 1.0.3 2025-01-10 [1] RSPM (R 4.4.0) fastmap 1.2.0 2024-05-15 [1] RSPM (R 4.4.0) fs 1.6.5 2024-10-30 [1] RSPM (R 4.4.0) generics 0.1.3 2022-07-05 [1] RSPM (R 4.4.0) glue 1.8.0 2024-09-30 [1] RSPM (R 4.4.0) hms 1.1.3 2023-03-21 [1] RSPM (R 4.4.0) htmltools 0.5.8.1 2024-04-04 [1] RSPM (R 4.4.0) httpuv 1.6.15 2024-03-26 [1] RSPM (R 4.4.0) jquerylib 0.1.4 2021-04-26 [1] RSPM (R 4.4.0) jsonlite 1.8.9 2024-09-20 [1] RSPM (R 4.4.0) knitr 1.49 2024-11-08 [1] RSPM (R 4.4.0) later 1.4.1 2024-11-27 [1] RSPM (R 4.4.0) lifecycle 1.0.4 2023-11-07 [1] RSPM (R 4.4.0) link * 2024.4.0 2024-03-11 [1] RSPM (R 4.4.0) logrx 0.4.0 2025-05-05 [1] RSPM (R 4.4.0) lubridate 1.9.4 2024-12-08 [1] RSPM (R 4.4.0) magrittr 2.0.3 2022-03-30 [1] RSPM (R 4.4.0) MedDataSets * 0.1.0 2024-10-24 [1] RSPM (R 4.4.0) memoise 2.0.1 2021-11-26 [1] RSPM (R 4.4.0) mime 0.12 2021-09-28 [1] RSPM (R 4.4.0) pharmaversesdtm * 1.2.0 2025-01-23 [1] RSPM (R 4.4.0) pillar 1.10.1 2025-01-07 [1] RSPM (R 4.4.0) pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.4.0) processx 3.8.5 2025-01-08 [1] RSPM (R 4.4.0) promises 1.3.2 2024-11-28 [1] RSPM (R 4.4.0) ps 1.8.1 2024-10-28 [1] RSPM (R 4.4.0) purrr 1.0.4 2025-02-05 [1] RSPM (R 4.4.0) quarto * 1.4.4 2024-07-20 [1] RSPM (R 4.4.0) R6 2.6.0 2025-02-12 [1] RSPM (R 4.4.0) Rcpp 1.0.14 2025-01-12 [1] RSPM (R 4.4.0) readr * 2.1.5 2024-01-10 [1] RSPM (R 4.4.0) rlang * 1.1.5 2025-01-17 [1] RSPM (R 4.4.0) rmarkdown 2.29 2024-11-04 [1] RSPM (R 4.4.0) rstudioapi 0.17.1 2024-10-22 [1] RSPM (R 4.4.0) sass 0.4.9 2024-03-15 [1] RSPM (R 4.4.0) sessioninfo 1.2.3 2025-02-05 [1] RSPM (R 4.4.0) shiny 1.10.0 2024-12-14 [1] RSPM (R 4.4.0) stringi 1.8.4 2024-05-06 [1] RSPM (R 4.4.0) stringr * 1.5.1 2023-11-14 [1] RSPM (R 4.4.0) tibble 3.2.1 2023-03-20 [1] RSPM (R 4.4.0) tidyr 1.3.1 2024-01-24 [1] RSPM (R 4.4.0) tidyselect 1.2.1 2024-03-11 [1] RSPM (R 4.4.0) timechange 0.3.0 2024-01-18 [1] RSPM (R 4.4.0) tzdb 0.4.0 2023-05-12 [1] RSPM (R 4.4.0) vctrs 0.6.5 2023-12-01 [1] RSPM (R 4.4.0) withr 3.0.2 2024-10-28 [1] RSPM (R 4.4.0) xfun 0.50 2025-01-07 [1] RSPM (R 4.4.0) xtable 1.8-4 2019-04-21 [1] RSPM (R 4.4.0) yaml 2.3.10 2024-07-26 [1] RSPM (R 4.4.0) [1] /cloud/lib/x86_64-pc-linux-gnu-library/4.4 [2] /opt/R/4.4.1/lib/R/library [3] /opt/R/4.4.2/lib/R/library [4] /opt/R/4.4.3/lib/R/library * ── Packages attached to the search path. ─ External software ──────────────────────────────────────────────────────────── setting value cairo 1.16.0 cairoFT pango 1.44.7 png 1.6.37 jpeg 8.0 tiff LIBTIFF, Version 4.1.0 tcl 8.6.10 curl 7.68.0 zlib 1.2.11 bzlib 1.0.8, 13-Jul-2019 xz 5.2.4 deflate PCRE 10.34 2019-11-21 ICU 66.1 TRE TRE 0.8.0 R_fixes (BSD) iconv glibc 2.31 readline 8.0 BLAS /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 lapack /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3 lapack_version 3.9.0 ─ Python configuration ───────────────────────────────────────────────────────── Python is not available ──────────────────────────────────────────────────────────────────────────────── -------------------------------------------------------------------------------- - Masked Functions - -------------------------------------------------------------------------------- function `words` from {package:stringr} by .GlobalEnv function `file` from {package:base} by .GlobalEnv function `replace` from {package:base} by .GlobalEnv function `as_label` from {package:dplyr} by package:rlang function `enexpr` from {package:dplyr} by package:rlang function `enexprs` from {package:dplyr} by package:rlang function `enquo` from {package:dplyr} by package:rlang function `enquos` from {package:dplyr} by package:rlang function `ensym` from {package:dplyr} by package:rlang function `ensyms` from {package:dplyr} by package:rlang function `expr` from {package:dplyr} by package:rlang function `quo` from {package:dplyr} by package:rlang function `quo_name` from {package:dplyr} by package:rlang function `quos` from {package:dplyr} by package:rlang function `sym` from {package:dplyr} by package:rlang function `syms` from {package:dplyr} by package:rlang function `%||%` from {package:base} by package:rlang function `assert_atomic_vector` from {package:checkmate} by package:admiraldev function `assert_data_frame` from {package:checkmate} by package:admiraldev function `assert_function` from {package:checkmate} by package:admiraldev function `assert_named` from {package:checkmate} by package:admiraldev function `anti_join` from {package:dplyr} by package:admiraldev function `filter_if` from {package:dplyr} by package:admiraldev function `inner_join` from {package:dplyr} by package:admiraldev function `left_join` from {package:dplyr} by package:admiraldev function `%>%` from {package:stringr} by package:dplyr function `filter` from {package:stats} by package:dplyr function `lag` from {package:stats} by package:dplyr function `intersect` from {package:base} by package:dplyr function `setdiff` from {package:base} by package:dplyr function `setequal` from {package:base} by package:dplyr function `union` from {package:base} by package:dplyr function `plot` from {package:base} by package:graphics function `body<-` from {package:base} by package:methods function `kronecker` from {package:base} by package:methods -------------------------------------------------------------------------------- - Used Package and Functions - -------------------------------------------------------------------------------- {package:base} library, requireNamespace, stop, message, tryCatch, print, nrow, warning {package:dplyr} %>%, filter, select {package:utils} data -------------------------------------------------------------------------------- - Program Run Time Information - -------------------------------------------------------------------------------- Start time: 2025-05-17 16:33:50 UTC End time: 2025-05-17 16:33:51 UTC Run time: 1 seconds -------------------------------------------------------------------------------- - Errors and Warnings - -------------------------------------------------------------------------------- Errors: Warnings: The filtered dataset has no data. Please check your filter criteria. -------------------------------------------------------------------------------- - Messages, Output, and Result - -------------------------------------------------------------------------------- Messages: Starting data manipulation using dplyr... Data manipulation completed. Output: Result: NULL -------------------------------------------------------------------------------- - Extra info - -------------------------------------------------------------------------------- - orange - green eggs and ham -------------------------------------------------------------------------------- - Log Output File - -------------------------------------------------------------------------------- Log name: logrx_test_file_extra_info1.log Log path: /cloud/project/posts/zzz_DO_NOT_EDIT_logrx_0.4.0...
Create a renv.lock
from a logrx
.log
file
A new vignette has been added to guide users in creating a
Shiny Addin Changes
As part of streamlining of logrx’s functionality, the Shiny Addin has been removed from the package. But don’t worry! It hasn’t disappeared entirely. A standalone package called
Conclusion
Happy logging of those R programs!
Last updated
2025-05-19 09:13:41.025152
Details
Reuse
Citation
Related