From ecce83d3096e1ce1abca2d2c846bc065d668bed1 Mon Sep 17 00:00:00 2001 From: Pawel Rucki <12943682+pawelru@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:12:06 +0100 Subject: [PATCH] register teal.logger handlers --- .pre-commit-config.yaml | 1 - DESCRIPTION | 8 ++++---- R/tm_a_pca.R | 2 +- R/tm_a_regression.R | 2 +- R/tm_data_table.R | 2 +- R/tm_file_viewer.R | 2 +- R/tm_front_page.R | 2 +- R/tm_g_association.R | 2 +- R/tm_g_bivariate.R | 2 +- R/tm_g_distribution.R | 2 +- R/tm_g_response.R | 2 +- R/tm_g_scatterplot.R | 2 +- R/tm_g_scatterplotmatrix.R | 2 +- R/tm_missing_data.R | 2 +- R/tm_outliers.R | 2 +- R/tm_t_crosstable.R | 2 +- R/tm_variable_browser.R | 2 +- R/zzz.R | 1 + tests/testthat/setup-logger.R | 1 + 19 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 tests/testthat/setup-logger.R diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 98d2f0dba..3958092f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,6 @@ repos: - DT - forcats - grid - - logger - magrittr - scales - shinyjs diff --git a/DESCRIPTION b/DESCRIPTION index 27ca55e99..1a3b458ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,6 @@ Imports: DT (>= 0.13), forcats (>= 1.0.0), grid, - logger (>= 0.2.0), magrittr (>= 1.5), scales, shinyjs, @@ -38,7 +37,7 @@ Imports: stats, stringr (>= 1.4.1), teal.code (>= 0.4.1.9009), - teal.logger (>= 0.1.1), + teal.logger (>= 0.1.3.9010), teal.reporter (>= 0.2.0), teal.widgets (>= 0.4.0), tern (>= 0.7.10), @@ -58,6 +57,7 @@ Suggests: jsonlite, knitr (>= 1.42), lattice (>= 0.18-4), + logger (>= 0.2.0), MASS, methods, nestcolor (>= 0.1.0), @@ -71,7 +71,7 @@ VignetteBuilder: Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2, rstudio/shiny, shinyTree/shinyTree, insightsengineering/teal, mllg/checkmate, tidyverse/dplyr, rstudio/DT, tidyverse/forcats, - daroczig/logger, tidyverse/magrittr, r-lib/scales, daattali/shinyjs, + tidyverse/magrittr, r-lib/scales, daattali/shinyjs, rstudio/shinyvalidate, dreamRs/shinyWidgets, tidyverse/stringr, insightsengineering/teal.code, insightsengineering/teal.logger, insightsengineering/teal.reporter, insightsengineering/teal.transform, @@ -79,7 +79,7 @@ Config/Needs/verdepcheck: haleyjeppson/ggmosaic, tidyverse/ggplot2, tidyverse/tibble, tidyverse/tidyr, r-lib/tidyselect, tidymodels/broom, daattali/colourpicker, daattali/ggExtra, aphalo/ggpmisc, aphalo/ggpp, baddstats/goftest, gridExtra, ramnathv/htmlwidgets, jeroen/jsonlite, - yihui/knitr, deepayan/lattice, MASS, insightsengineering/nestcolor, + yihui/knitr, deepayan/lattice, daroczig/logger, MASS, insightsengineering/nestcolor, r-lib/rlang, insightsengineering/rtables, sparkline, insightsengineering/teal.data, r-lib/testthat Config/Needs/website: insightsengineering/nesttemplate diff --git a/R/tm_a_pca.R b/R/tm_a_pca.R index 1606862a8..0288522fc 100644 --- a/R/tm_a_pca.R +++ b/R/tm_a_pca.R @@ -69,7 +69,7 @@ tm_a_pca <- function(label = "Principal Component Analysis", size = c(2, 1, 8), pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_a_pca") + message("Initializing tm_a_pca") if (inherits(dat, "data_extract_spec")) dat <- list(dat) if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args) diff --git a/R/tm_a_regression.R b/R/tm_a_regression.R index 34e25eee3..bec1e7a3e 100644 --- a/R/tm_a_regression.R +++ b/R/tm_a_regression.R @@ -93,7 +93,7 @@ tm_a_regression <- function(label = "Regression Analysis", post_output = NULL, default_plot_type = 1, default_outlier_label = "USUBJID") { - logger::log_info("Initializing tm_a_regression") + message("Initializing tm_a_regression") if (inherits(regressor, "data_extract_spec")) regressor <- list(regressor) if (inherits(response, "data_extract_spec")) response <- list(response) if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args) diff --git a/R/tm_data_table.R b/R/tm_data_table.R index ad20cc078..36da1451f 100644 --- a/R/tm_data_table.R +++ b/R/tm_data_table.R @@ -62,7 +62,7 @@ tm_data_table <- function(label = "Data Table", server_rendering = FALSE, pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_data_table") + message("Initializing tm_data_table") checkmate::assert_string(label) checkmate::assert_list(variables_selected, min.len = 0, types = "character", names = "named") if (length(variables_selected) > 0) { diff --git a/R/tm_file_viewer.R b/R/tm_file_viewer.R index deb5632a0..86c9eca13 100644 --- a/R/tm_file_viewer.R +++ b/R/tm_file_viewer.R @@ -39,7 +39,7 @@ #' tm_file_viewer <- function(label = "File Viewer Module", input_path = list("Current Working Directory" = ".")) { - logger::log_info("Initializing tm_file_viewer") + message("Initializing tm_file_viewer") if (length(label) == 0 || identical(label, "")) { label <- " " } diff --git a/R/tm_front_page.R b/R/tm_front_page.R index aa755d64f..c49c38874 100644 --- a/R/tm_front_page.R +++ b/R/tm_front_page.R @@ -70,7 +70,7 @@ tm_front_page <- function(label = "Front page", checkmate::assert_character(footnotes, min.len = 0, any.missing = FALSE) checkmate::assert_flag(show_metadata) - logger::log_info("Initializing tm_front_page") + message("Initializing tm_front_page") args <- as.list(environment()) module( diff --git a/R/tm_g_association.R b/R/tm_g_association.R index 2a4bf5625..d9a63d990 100644 --- a/R/tm_g_association.R +++ b/R/tm_g_association.R @@ -89,7 +89,7 @@ tm_g_association <- function(label = "Association", pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { - logger::log_info("Initializing tm_g_association") + message("Initializing tm_g_association") if (inherits(ref, "data_extract_spec")) ref <- list(ref) if (inherits(vars, "data_extract_spec")) vars <- list(vars) if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args) diff --git a/R/tm_g_bivariate.R b/R/tm_g_bivariate.R index 2ec66c397..262e93a1e 100644 --- a/R/tm_g_bivariate.R +++ b/R/tm_g_bivariate.R @@ -125,7 +125,7 @@ tm_g_bivariate <- function(label = "Bivariate Plots", ggplot2_args = teal.widgets::ggplot2_args(), pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_g_bivariate") + message("Initializing tm_g_bivariate") if (inherits(x, "data_extract_spec")) x <- list(x) if (inherits(y, "data_extract_spec")) y <- list(y) if (inherits(row_facet, "data_extract_spec")) row_facet <- list(row_facet) diff --git a/R/tm_g_distribution.R b/R/tm_g_distribution.R index 310b95cfd..3b236df18 100644 --- a/R/tm_g_distribution.R +++ b/R/tm_g_distribution.R @@ -119,7 +119,7 @@ tm_g_distribution <- function(label = "Distribution Module", plot_width = NULL, pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_g_distribution") + message("Initializing tm_g_distribution") extra_packages <- c("ggpmisc", "ggpp", "goftest", "MASS", "broom") missing_packages <- Filter(function(x) !requireNamespace(x, quietly = TRUE), extra_packages) diff --git a/R/tm_g_response.R b/R/tm_g_response.R index ce0c60a86..d239b2aae 100644 --- a/R/tm_g_response.R +++ b/R/tm_g_response.R @@ -85,7 +85,7 @@ tm_g_response <- function(label = "Response Plot", ggplot2_args = teal.widgets::ggplot2_args(), pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_g_response") + message("Initializing tm_g_response") if (inherits(response, "data_extract_spec")) response <- list(response) if (inherits(x, "data_extract_spec")) x <- list(x) if (inherits(row_facet, "data_extract_spec")) row_facet <- list(row_facet) diff --git a/R/tm_g_scatterplot.R b/R/tm_g_scatterplot.R index cae83d74d..da498f7bd 100644 --- a/R/tm_g_scatterplot.R +++ b/R/tm_g_scatterplot.R @@ -160,7 +160,7 @@ tm_g_scatterplot <- function(label = "Scatterplot", post_output = NULL, table_dec = 4, ggplot2_args = teal.widgets::ggplot2_args()) { - logger::log_info("Initializing tm_g_scatterplot") + message("Initializing tm_g_scatterplot") extra_packages <- c("ggpmisc", "ggExtra", "colourpicker") missing_packages <- Filter(function(x) !requireNamespace(x, quietly = TRUE), extra_packages) diff --git a/R/tm_g_scatterplotmatrix.R b/R/tm_g_scatterplotmatrix.R index f7c26eddf..009c23166 100644 --- a/R/tm_g_scatterplotmatrix.R +++ b/R/tm_g_scatterplotmatrix.R @@ -77,7 +77,7 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix", plot_width = NULL, pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_g_scatterplotmatrix") + message("Initializing tm_g_scatterplotmatrix") if (!requireNamespace("lattice", quietly = TRUE)) { stop("Cannot load lattice - please install the package or restart your session.") } diff --git a/R/tm_missing_data.R b/R/tm_missing_data.R index c8b502da9..f0eab432d 100644 --- a/R/tm_missing_data.R +++ b/R/tm_missing_data.R @@ -64,7 +64,7 @@ tm_missing_data <- function(label = "Missing data", if (!requireNamespace("rlang", quietly = TRUE)) { stop("Cannot load rlang - please install the package or restart your session.") } - logger::log_info("Initializing tm_missing_data") + message("Initializing tm_missing_data") if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args) checkmate::assert_string(label) diff --git a/R/tm_outliers.R b/R/tm_outliers.R index 42b5976ef..e471d7345 100644 --- a/R/tm_outliers.R +++ b/R/tm_outliers.R @@ -75,7 +75,7 @@ tm_outliers <- function(label = "Outliers Module", plot_width = NULL, pre_output = NULL, post_output = NULL) { - logger::log_info("Initializing tm_outliers") + message("Initializing tm_outliers") if (inherits(outlier_var, "data_extract_spec")) outlier_var <- list(outlier_var) if (inherits(categorical_var, "data_extract_spec")) categorical_var <- list(categorical_var) if (inherits(ggplot2_args, "ggplot2_args")) ggplot2_args <- list(default = ggplot2_args) diff --git a/R/tm_t_crosstable.R b/R/tm_t_crosstable.R index 49ba6afd2..463da272e 100644 --- a/R/tm_t_crosstable.R +++ b/R/tm_t_crosstable.R @@ -80,7 +80,7 @@ tm_t_crosstable <- function(label = "Cross Table", pre_output = NULL, post_output = NULL, basic_table_args = teal.widgets::basic_table_args()) { - logger::log_info("Initializing tm_t_crosstable") + message("Initializing tm_t_crosstable") if (!requireNamespace("rtables", quietly = TRUE)) { stop("Cannot load rtables - please install the package or restart your session.") } diff --git a/R/tm_variable_browser.R b/R/tm_variable_browser.R index 901d3ca18..06a371013 100644 --- a/R/tm_variable_browser.R +++ b/R/tm_variable_browser.R @@ -62,7 +62,7 @@ tm_variable_browser <- function(label = "Variable Browser", pre_output = NULL, post_output = NULL, ggplot2_args = teal.widgets::ggplot2_args()) { - logger::log_info("Initializing tm_variable_browser") + message("Initializing tm_variable_browser") if (!requireNamespace("sparkline", quietly = TRUE)) { stop("Cannot load sparkline - please install the package or restart your session.") } diff --git a/R/zzz.R b/R/zzz.R index c99f35e18..74a1cc062 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,3 +1,4 @@ .onLoad <- function(libname, pkgname) { # nolint teal.logger::register_logger(namespace = "teal.modules.general") + teal.logger::register_handlers("teal.modules.general") } diff --git a/tests/testthat/setup-logger.R b/tests/testthat/setup-logger.R new file mode 100644 index 000000000..f6401f548 --- /dev/null +++ b/tests/testthat/setup-logger.R @@ -0,0 +1 @@ +logger::log_appender(function(...) NULL, namespace = "teal.modules.general")