Skip to content

feat: replace logger with lightweight console logging + ZIP export#1212

Draft
Gero1999 wants to merge 4 commits intomainfrom
1210-enhancement/replace-logger-with-console
Draft

feat: replace logger with lightweight console logging + ZIP export#1212
Gero1999 wants to merge 4 commits intomainfrom
1210-enhancement/replace-logger-with-console

Conversation

@Gero1999
Copy link
Copy Markdown
Collaborator

@Gero1999 Gero1999 commented Apr 9, 2026

Issue

Closes #1210

Description

Replaces the logger package with a lightweight internal logging system. Log messages are printed to the R console and captured in memory so they can be exported as session_log.txt in the ZIP download.

What changed:

  • New file inst/shiny/functions/logging.R — drop-in replacements for log_trace, log_debug, log_info, log_success, log_warn, log_error, and log_debug_list. Supports glue-style {var} interpolation and paste-style multi-argument calls. Threshold configurable via aNCA_LOG_LEVEL env var (default: INFO).
  • Removed setup_logger() and log_debug_list() from utils.R (now in logging.R).
  • Removed require(logger) from app.R.
  • Moved logger from Imports back to Suggests in DESCRIPTION.
  • Added session_log to the ZIP export tree — the in-memory log buffer is written to session_log.txt alongside session_info.txt.

What no longer happens:

  • No log files are written to the filesystem (./log directory). All output goes to the console and the in-memory buffer.

Definition of Done

  • App starts without logger installed.
  • Log messages appear in the R console at the configured threshold level.
  • ZIP export includes session_log.txt with the session's log entries.

How to test

  1. Uninstall logger (or test in a clean environment).
  2. Run aNCA::run_app() — should start without errors.
  3. Upload data, run NCA, and observe log messages in the R console.
  4. Export results as ZIP and verify session_log.txt is included with log entries.
  5. Set aNCA_LOG_LEVEL=TRACE in .Renviron and verify more verbose output.

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented
  • App or package changes are reflected in NEWS
  • Package version is incremented
  • R script works with the new implementation (if applicable)
  • Settings upload works with the new implementation (if applicable)
  • If any .scss change was done, run data-raw/compile_css.R

Notes to reviewer

All 48 existing log_* calls across the Shiny modules work unchanged — the new functions have the same signatures and support both glue interpolation (log_info(\"Processing {n} items\")) and paste-style (log_info(\"Processing: \", n, \" items\")).

The aNCA_LOG_LEVEL env var is still respected, same as before.

Version bump and NEWS entry still needed before merge.

Gero1999 and others added 3 commits April 9, 2026 11:02
Move packages that are required for run_app() from Suggests to Imports
so they are installed automatically with install.packages('aNCA').

Moved to Imports: bslib, htmltools, htmlwidgets, logger,
reactable, reactable.extras, shiny, shinycssloaders, shinyjs,
shinyjqui, shinyWidgets, zip.

Removed stringi dependency entirely, replaced with base R
paste0(sample()) for random string generation.

Simplified check_app_dependencies() since all core app packages
are now guaranteed by Imports.

Co-authored-by: Ona <no-reply@ona.com>
later is always available when shiny is installed. No need to list
it explicitly in DESCRIPTION.

Co-authored-by: Ona <no-reply@ona.com>
Replace the logger package dependency with an internal logging system
that outputs to the R console and captures logs in memory. The session
log can be exported as session_log.txt in the ZIP download.

- Add inst/shiny/functions/logging.R with log_trace/debug/info/success/
  warn/error functions, glue interpolation, configurable threshold via
  aNCA_LOG_LEVEL env var, and in-memory buffer
- Remove setup_logger and log_debug_list from utils.R (now in logging.R)
- Remove require(logger) from app.R
- Move logger from Imports back to Suggests in DESCRIPTION
- Add session_log to ZIP export tree and file filtering

Closes #1210

Co-authored-by: Ona <no-reply@ona.com>
@bachapman
Copy link
Copy Markdown
Collaborator

With this, are there any contributing guidelines for what activity should be logged and what should not be? For reference for future function/feature implementation.

@Gero1999
Copy link
Copy Markdown
Collaborator Author

@bachapman good point Bryce, probably we can include something for this. Either add a website page for the log file and then add the link somewhere in the App.

Perhaps would be also a good idea to put a help button in the Export modal message with all output explanations/links.

@Gero1999
Copy link
Copy Markdown
Collaborator Author

Or maybe is easier if we add commented lines at the top of the file to explain what is captured. Currently we are tracking this, the strategy is always to capture errors/warnings in the most data-sensitive points (mapping, NCA settings, NCA run):

Workflow Stage What's Logged Levels
Startup App initialization INFO
Data Upload File paths, load success/failure, file errors INFO, SUCCESS, ERROR
Settings Settings restore/load success, load failures SUCCESS, ERROR
Data Mapping Mapping start, mapping warnings, mapping errors INFO, WARN, ERROR
Data Filtering Filter warnings WARN
NCA Setup Parameter selection count, PKNCA object lifecycle, units, slope edits INFO, TRACE, SUCCESS
NCA Calculation Calculation start, warnings (e.g. half-life issues), success, errors INFO, WARN, SUCCESS, ERROR
Exploration Plots Plot render, save, remove INFO
TLG Generation Module attachment, submitted TLG list TRACE, DEBUG
Export Summary stats download INFO

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.

Enhancement: Replace logger dependency with console-only logging + ZIP export

2 participants