Skip to content

Commit

Permalink
Adding shinylogs recording to app
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Jung committed Apr 29, 2024
1 parent ee8aa2b commit 720a1f1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ tests/testthat/*.pdf

# Shiny bookmarks
shiny_bookmarks/

# Ignore log files
logs/
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Imports:
shinyWidgets,
shinyjs,
shinyFeedback,
shinylogs,
sever,
fresh,
DT,
Expand Down
6 changes: 6 additions & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ app_server <- function(input, output, session) {
session$doBookmark()
})

# Enable shinylogs
# shinylogs::read_rds_logs("logs")
shinylogs::track_usage(what = c("session", "input", "output", "error"),
storage_mode = shinylogs::store_rds(path = "logs/")
)

# fake reload at start
shiny::observeEvent(input$reload, {
session$reload()
Expand Down
20 changes: 20 additions & 0 deletions dev/rm_logs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This maintenance script simply deletes all files in the log folder of the app
# To run simply do Rscript inst/rm_logs.R
# --- #

library(assertthat)

# Get all log files
ll <- list.files("logs/", full.names = TRUE)
ll <- ll[assertthat::has_extension(ll, "rds")]

# No logs found
if(length(ll)==0){
message("No logs found...")
} else {
# Message
message("Found a total of ", length(ll), " log files. Deleting them all?")
if(utils::askYesNo(msg = "Delete?")){
sapply(ll, file.remove)
}
}

0 comments on commit 720a1f1

Please sign in to comment.