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

New arguments for log_shiny_input_changes #154

Closed
wants to merge 1 commit into from

Conversation

m7pr
Copy link
Contributor

@m7pr m7pr commented May 14, 2024

This PR introduces 3 new parameters

#' @param allow allow to be used outside Shiny app
#' @param change_message custom message to be displayed during the input change - supports `glue` syntax where `{name}`
#' is the name of the input, and `{old}` and `{new}` are input values before the change and after the change
#' @param initialize_message custom message to be displayed during input initialization (this is followed by initialized
#' input values being printed in JSON format)

@param allow

allow is needed to skip the stop() statement that blocks the usage of log_shiny_input_changes outside of Shiny app. However there are use cases where the usage outside Shiny app make sense, e.g. in Shiny Tests:

library(shiny)
server <- function(input, output, session) {
  logger::log_shiny_input_changes()
  x <- reactive(input$a * input$b)
}

testServer(server, {
  session$setInputs(a = 2, b = 3)
  stopifnot(x() == 6)
})
Error in logger::log_shiny_input_changes() :
No Shiny app running, it makes no sense to call this function outside of a Shiny app

@param *_message

If there is multiple server modules that utilize log_shiny_input_changes with similar input names, it would be beneficial to be able to append the log_shiny_input_changes messages with user-defined messages (e.g. such messages that include name of the function in the message). So I proposed to have messages used in this function as parameters that a user can overwrite.

@m7pr
Copy link
Contributor Author

m7pr commented May 14, 2024

@daroczig or we could extend existing messages so they display namespace

ns <- session$ns("")
log_level(level, "Shiny input change detected in {ns} on {name}: {old} -> {new}", namespace = namespace)

@m7pr
Copy link
Contributor Author

m7pr commented May 14, 2024

clsoing this in favour of #155

@m7pr m7pr closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant