Title: | A Logging Utility Focus on Clinical Trial Programming Workflows |
---|---|
Description: | A utility to facilitate the logging and review of R programs in clinical trial programming workflows. |
Authors: | Nathan Kosiba [aut, cre], Thomas Bermudez [aut], Ben Straub [aut], Michael Rimler [aut], Nicholas Masel [aut], Sam Parmar [aut], GSK/Atorus JPT [cph, fnd] |
Maintainer: | Nathan Kosiba <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.1 |
Built: | 2024-10-09 05:00:44 UTC |
Source: | https://github.com/pharmaverse/logrx |
A dataset that stores approved packages and functions for use.
Each row contains a library
and function_name
.
This dataset is used to illustrate the data format to be stored in
the log.rx.approved option.
approved
approved
A tibble with 6 rows and 2 variables:
Name of the function
Name of the package
logrx::approved
logrx::approved
axecute()
creates a log, executes a file, and returns 0 if there are no
errors or 1 if there are any errors
axecute( file, log_name = NA, log_path = NA, include_rds = FALSE, quit_on_error = TRUE, to_report = c("messages", "output", "result"), show_repo_url = FALSE, ... )
axecute( file, log_name = NA, log_path = NA, include_rds = FALSE, quit_on_error = TRUE, to_report = c("messages", "output", "result"), show_repo_url = FALSE, ... )
file |
String. Path to file to execute |
log_name |
String. Name of log file |
log_path |
String. Path to log file |
include_rds |
Boolean. Option to export log object as Rds file. Defaults to FALSE |
quit_on_error |
Boolean. Should the session quit with status 1 on error? Defaults to TRUE |
to_report |
String vector. Objects to optionally report, may include as many as necessary:
|
show_repo_url |
Boolean. Should the repository URLs be reported Defaults to FALSE |
... |
Not used |
0 if there are no errors or 1 if there are any errors
dir <- tempdir() text <- 'print("Hello, logrxperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) axecute(file.path(dir, "hello.R")) fileConn <- file(file.path(dir, "hello.Rmd")) writeLines(text, fileConn) close(fileConn) axecute(file.path(dir, "hello.Rmd"))
dir <- tempdir() text <- 'print("Hello, logrxperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) axecute(file.path(dir, "hello.R")) fileConn <- file(file.path(dir, "hello.Rmd")) writeLines(text, fileConn) close(fileConn) axecute(file.path(dir, "hello.Rmd"))
A utility function to help you build your approved packages and functions list. This can be used by logrx to log unapproved use of packages and functions.
build_approved(pkg_list, file = NULL)
build_approved(pkg_list, file = NULL)
pkg_list |
Named list of character vectors:
|
file |
String. Name of file where the approved tibble will be written to. If not specified, the tibble is returned Default: NULL Permitted Files: .RDS |
For more details see the vignette:
vignette("approved", package = "logrx")
Tibble with two columns (library, function) and one row per function
approved_pkgs <- list( base = c("library", "mean"), dplyr = "All" ) # build and return build_approved(approved_pkgs) # build and save dir <- tempdir() build_approved(approved_pkgs, file.path(dir, "approved.rds"))
approved_pkgs <- list( base = c("library", "mean"), dplyr = "All" ) # build and return build_approved(approved_pkgs) # build and save dir <- tempdir() build_approved(approved_pkgs, file.path(dir, "approved.rds"))
log_config()
initialises the log.rx environment, adds its attributes, and
sets them
log_config(file = NA, log_name = NA, log_path = NA)
log_config(file = NA, log_name = NA, log_path = NA)
file |
String. Path to file executed. Optional |
log_name |
String. Name of log file. Optional |
log_path |
String. Path to log file. Optional |
Nothing
dir <- tempdir() text <- 'print("Hello, Timberperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) file <- file.path(dir, "hello.R") # Initialise and configure the log.rx environment log_config(file) # Run the script and record results, outputs, messages, errors, and warnings logrx:::run_safely_loudly(file) # Write the log log_write(file)
dir <- tempdir() text <- 'print("Hello, Timberperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) file <- file.path(dir, "hello.R") # Initialise and configure the log.rx environment log_config(file) # Run the script and record results, outputs, messages, errors, and warnings logrx:::run_safely_loudly(file) # Write the log log_write(file)
log_init()
initialises the log.rx environment
log_init()
log_init()
Nothing
# Initialise the log.rx environment log_init() # Remove the log.rx environment log_remove()
# Initialise the log.rx environment log_init() # Remove the log.rx environment log_remove()
log_remove()
removes the log.rx object by setting options("log.rx")
to
NULL
log_remove()
log_remove()
Nothing
# Initialise the log.rx environment log_init() # Remove the log.rx environment log_remove()
# Initialise the log.rx environment log_init() # Remove the log.rx environment log_remove()
log_write()
gets and formats the content of the log.rx before writing it
to a log file
log_write( file = NA, remove_log_object = TRUE, show_repo_url = FALSE, include_rds = FALSE, to_report = c("messages", "output", "result") )
log_write( file = NA, remove_log_object = TRUE, show_repo_url = FALSE, include_rds = FALSE, to_report = c("messages", "output", "result") )
file |
String. Path to file executed |
remove_log_object |
Boolean. Should the log object be removed after writing the log file? Defaults to TRUE |
show_repo_url |
Boolean. Should the repo URLs be reported Defaults to FALSE |
include_rds |
Boolean. Option to export log object as Rds file. Defaults to FALSE |
to_report |
String vector. Objects to optionally report; additional
information in |
Nothing
dir <- tempdir() text <- 'print("Hello, Timberperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) file <- file.path(dir, "hello.R") # Initialise and configure the log.rx environment log_config(file) # Run the script and record results, outputs, messages, errors, and warnings logrx:::run_safely_loudly(file) # Write the log log_write(file)
dir <- tempdir() text <- 'print("Hello, Timberperson!")' fileConn <- file(file.path(dir, "hello.R")) writeLines(text, fileConn) close(fileConn) file <- file.path(dir, "hello.R") # Initialise and configure the log.rx environment log_config(file) # Run the script and record results, outputs, messages, errors, and warnings logrx:::run_safely_loudly(file) # Write the log log_write(file)
Read and parse logrx file
read_log_file(file)
read_log_file(file)
file |
String. Path to a logrx log file |
Tibble. Object that includes nested and parsed content
## Not run: read_log_file(previous_log_filepath) ## End(Not run)
## Not run: read_log_file(previous_log_filepath) ## End(Not run)
write_log_header
formats a string and returns it as a formatted log file
section header
write_log_header(title_string)
write_log_header(title_string)
title_string |
String. Used as section title |
Vector of strings. Formatted log file section header
## Not run: write_log_header("Section Header") ## End(Not run)
## Not run: write_log_header("Section Header") ## End(Not run)
write_unapproved_functions()
gets log.rx unapproved_packages_functions
attribute, formats and returns the list of unapproved functions
write_unapproved_functions()
write_unapproved_functions()
Formatted vector of unapproved functions
## Not run: write_unapproved_functions() ## End(Not run)
## Not run: write_unapproved_functions() ## End(Not run)
write_used_functions()
gets log.rx used_packages_functions attribute,
formats and returns the list of used package functions
write_used_functions()
write_used_functions()
Formatted vector of used package functions
## Not run: write_used_functions() ## End(Not run)
## Not run: write_used_functions() ## End(Not run)