Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(logging): added logging support #240

Merged
merged 5 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

* Added R version requirement, R >= 3.6.

## Enhancements
* Added support for logging with the `logger` package and added info level logs upon initialization of a module.

# teal.modules.general 0.2.11

### New features
Expand Down
3 changes: 2 additions & 1 deletion R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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")
stopifnot(is_character_single(label))
stopifnot(is_class_list("data_extract_spec")(dat) || is(dat, "data_extract_spec"))

Expand Down Expand Up @@ -207,6 +207,7 @@ ui_a_pca <- function(id, ...) {
}

srv_a_pca <- function(input, output, session, datasets, dat, plot_height, plot_width) {
logger::log_shiny_input_changes()
Polkas marked this conversation as resolved.
Show resolved Hide resolved
response <- dat

for (i in seq_along(response)) {
Expand Down
1 change: 1 addition & 0 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,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")
if (!is_class_list("data_extract_spec")(regressor)) {
regressor <- list(regressor)
}
Expand Down
3 changes: 1 addition & 2 deletions R/tm_data_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ tm_data_table <- function(label = "Data Table",
scrollX = TRUE),
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_data_table")
stop_if_not(
is_character_single(label),
is.list(variables_selected),
Expand Down Expand Up @@ -343,8 +344,6 @@ srv_data_table <- function(input,

validate(need(variables, "need valid variable names"))

.log("data table update", dataname)

df <- datasets$get_data(
dataname,
filtered = if_filtered()
Expand Down
2 changes: 1 addition & 1 deletion R/tm_file_viewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#'
tm_file_viewer <- function(label = "File Viewer Module",
input_path = list("Current Working Directory" = ".")) {

logger::log_info("Initializing tm_file_viewer")
if (is.null(label) || length(label) == 0 || label == "") {
label <- " "
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ tm_g_association <- function(label = "Association",
association_theme = gg_themes,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_g_association")
if (!is_class_list("data_extract_spec")(ref)) {
ref <- list(ref)
}
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ tm_g_bivariate <- function(label = "Bivariate Plots",
ggtheme = gg_themes,
pre_output = NULL,
post_output = NULL) {

logger::log_info("Initializing tm_g_bivariate")
ggtheme <- match.arg(ggtheme)

stop_if_not(
Expand Down
2 changes: 1 addition & 1 deletion R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tm_g_distribution <- function(label = "Distribution Module",
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {

logger::log_info("Initializing tm_g_distribution")
if (!is.null(dist_var) && !is_class_list("data_extract_spec")(dist_var)) {
dist_var <- list(dist_var)
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ tm_g_response <- function(label = "Response Plot",
ggtheme = gg_themes,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_g_response")
if (!is_class_list("data_extract_spec")(response)) {
response <- list(response)
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ tm_g_scatterplot <- function(label = "Scatterplot",
pre_output = NULL,
post_output = NULL,
table_dec = 4) {
logger::log_info("Initializing tm_g_scatterplot")
if (!is_class_list("data_extract_spec")(x)) {
x <- list(x)
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tm_g_scatterplotmatrix <- function(label = "Scatterplot Matrix",
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_g_scatterplotmatrix")
if (!is_class_list("data_extract_spec")(variables)) {
variables <- list(variables)
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tm_missing_data <- function(label = "Missing data",
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_missing_data")
stopifnot(is_character_single(label))
check_slider_input(plot_height, allow_null = FALSE)
check_slider_input(plot_width)
Expand Down
1 change: 1 addition & 0 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ tm_outliers <- function(label = "Outliers Module",
plot_width = NULL,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_outliers")
if (!is_class_list("data_extract_spec")(outlier_var)) {
outlier_var <- list(outlier_var)
}
Expand Down
1 change: 1 addition & 0 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tm_t_crosstable <- function(label = "Cross Table",
show_total = TRUE,
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_t_crosstable")
stop_if_not(
is_character_single(label),
is_class_list("data_extract_spec")(x) || is(x, "data_extract_spec"),
Expand Down
5 changes: 1 addition & 4 deletions R/tm_variable_browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ tm_variable_browser <- function(label = "Variable Browser",
datasets_selected = character(0),
pre_output = NULL,
post_output = NULL) {
logger::log_info("Initializing tm_variable_browser")
stop_if_not(is_character_single(label),
is_character_empty(datasets_selected) || is_character_vector(datasets_selected)
)
Expand Down Expand Up @@ -903,8 +904,6 @@ get_plotted_data <- function(input, plot_var, datasets) {
type <- input$raw_or_filtered
df <- datasets$get_data(dataset_name, filtered = type)

.log("plot/summarize variable", varname, "for data", dataset_name, "(", `if`(type, "filtered", "raw"), ")")

var_description <- get_var_description(datasets = datasets, dataset_name = dataset_name, var_name = varname)
list(data = df[[varname]], var_description = var_description)
}
Expand Down Expand Up @@ -936,8 +935,6 @@ render_tabset_panel_content <- function(datanames, output, datasets, input, colu
#' @param dataset_name (`character`) the name of the dataset contained in the rendered tab
#' @inheritParams render_tabset_panel_content
render_single_tab <- function(dataset_name, output, datasets, input, columns_names, plot_var) {
.log("variable label table:", dataset_name)

render_tab_header(dataset_name, output, datasets)

render_tab_table(
Expand Down
3 changes: 3 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onLoad <- function(libname, pkgname) { # nolint
teal::register_logger(namespace = "teal.modules.general")
}