Skip to content

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

Draft
Gero1999 wants to merge 30 commits into
mainfrom
1210-enhancement/replace-logger-with-console
Draft

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

Conversation

@Gero1999

@Gero1999 Gero1999 commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

Issue

Closes #1210

Merges reviewed changes from:

What to review

Most of the diff comes from child PRs that were already reviewed and merged into this branch. The new code unique to this PR is:

File What's new
inst/shiny/functions/logging.R The entire logging system (~84 lines)
inst/shiny/functions/utils.R Removal of old setup_logger()
inst/shiny/modules/tab_nca/zip.R session_log added to TREE_LIST$extras
inst/shiny/functions/zip-utils.R .export_session_log() function
inst/shiny/modules/tab_nca.R setup_logger() call
DESCRIPTION / NAMESPACE / R/imports-shiny.R logger package removal

Everything else in the diff is either from #1221 (log-points), #1222 (documentation), or merge commits from main.

Description

Replaces the logger package with a lightweight internal logging system. Log messages are written to the R console via message() and captured in an in-memory buffer that is exported as session_log.txt in the ZIP download.

Core logging system

  • New inst/shiny/functions/logging.R with log_trace, log_debug, log_info, log_success, log_warn, log_error
  • In-memory buffer (get_log_buffer()) for ZIP export
  • Configurable threshold via aNCA_LOG_LEVEL env var (default: INFO)
  • Removed logger from Imports and Suggests, removed setup_logger() from utils.R

NCA input log-points (#1221 — already reviewed)

  • Analyte, specimen, profile, method, min half-life points, flag rules, BLQ strategy, C0 imputation changes logged at INFO
  • Parameter selection count per study type logged at INFO (debounced)
  • Slope rule changes logged at INFO (only on user actions, not programmatic updates)
  • Exclusion add/remove logged at INFO
  • Initialization noise suppressed via filters_initialized guard

Session log documentation (#1222 — already reviewed)

  • session_log.txt includes a header block explaining contents, threshold, and link to reference page
  • vignettes/session_log.Rmd — full reference of logged events by workflow stage
  • Added "Session Log Reference" to pkgdown navbar under Developer Resources
  • Scope clarification added to logging.R header

ZIP export

  • session_log added to TREE_LIST$extras (available with or without NCA results)
  • .export_session_log() writes the buffer with header to session_log.txt

Definition of Done

  • logger package fully removed (no imports, no Suggests, no require)
  • All existing log_* calls work with the new system
  • NCA user input changes appear in the session log
  • session_log.txt exported in ZIP with explanatory header
  • No log noise during initialization or settings restore

How to test

  1. Run aNCA::run_app()
  2. Upload data, map columns, navigate to NCA
  3. Change settings (analyte, method, flag rules, etc.), add/remove slope rules and exclusions
  4. Verify log messages appear in the R console
  5. Export ZIP — verify session_log.txt is present with header and log entries
  6. Set aNCA_LOG_LEVEL=TRACE 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

The logger package is fully removed — not just from Imports but also from Suggests and NAMESPACE. The @importFrom logger log_info in R/imports-shiny.R has been removed.

The parameter selection logging was adapted to main's matrix-based UI (the old sub-module approach via param_selector_panel_server no longer exists).

Version bump and NEWS entry still needed before merge.

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

Gero1999 and others added 5 commits April 14, 2026 10:03
Log analyte, specimen, profile, method, min half-life points,
and flag rule changes at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log the full list of selected parameters at DEBUG level
alongside the existing INFO count message.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Upgrade slope rule add/remove from TRACE to INFO level.
Add DEBUG summary of slope rules count on table changes.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log exclusion add (with row count, type, reason), removal,
and settings restore at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log NCA profile changes, BLQ strategy changes, and C0
imputation toggle at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Gero1999 and others added 16 commits April 14, 2026 13:20
Replace all glue-style log calls ({var}) with paste-style
(multiple arguments) to avoid parent.frame(2) scoping issues
in closures and observeEvent callbacks. Guard profile log
against NA values.

Co-authored-by: Ona <no-reply@ona.com>
Log analyte, specimen, profile, method, min half-life points,
and flag rule changes at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log the full list of selected parameters at DEBUG level
alongside the existing INFO count message.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Upgrade slope rule add/remove from TRACE to INFO level.
Add DEBUG summary of slope rules count on table changes.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log exclusion add (with row count, type, reason), removal,
and settings restore at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Log NCA profile changes, BLQ strategy changes, and C0
imputation toggle at INFO level.

Closes #1219 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Replace all glue-style log calls ({var}) with paste-style
(multiple arguments) to avoid parent.frame(2) scoping issues
in closures and observeEvent callbacks. Guard profile log
against NA values.

Co-authored-by: Ona <no-reply@ona.com>
Include explanation of what the log captures, current threshold,
visible levels, and a link to the full reference page.

Closes #1220 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Developer website page documenting all logged events by workflow
stage, log levels, and configuration via aNCA_LOG_LEVEL.

Closes #1220 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Add 'Session Log Reference' entry under Developer Resources
in the website navigation.

Closes #1220 (partial)

Co-authored-by: Ona <no-reply@ona.com>
Clarify what the log captures vs. what it does not, and link
to the full session log reference page.

Closes #1220 (partial)

Co-authored-by: Ona <no-reply@ona.com>
…ession-logs

docs: document session log contents
Replace separate add/remove INFO messages with a single INFO
summary that fires on any slope table change (button clicks,
plotly point selections, cell edits). Demote add/remove to TRACE.

Co-authored-by: Ona <no-reply@ona.com>
- Suppress analyte/specimen/profile logs during initial data load
  using a filters_initialized guard
- Move profile log to dedicated observeEvent(input$select_profile)
  with ignoreInit = TRUE
- Move exclusion-add logging inside .handle_add_exclusion to avoid
  duplicating input reads
- Use 'selections' instead of 'inclusions' in slope log to match
  the UI terminology (TYPE == 'Selection')

Co-authored-by: Ona <no-reply@ona.com>
Gero1999 and others added 7 commits April 24, 2026 12:30
- Convert remaining glue-style log calls to paste-style
  (parameter_selection.R log_info, manual_slopes_table.R log_trace)
- Add filters_initialized guard to method and min_hl_points
  observers to suppress logs during settings restore

Co-authored-by: Ona <no-reply@ona.com>
Add user_changed_slopes flag to only log slope rule changes
triggered by user actions (plotly clicks, add/remove buttons),
not by settings restore or initial render.

Co-authored-by: Ona <no-reply@ona.com>
…log-points

feat: add log-points for NCA user input changes
Resolve conflicts:
- parameter_selection.R: keep both log-points and new clear_all observer
- settings.R: keep filters_initialized guard with updated pending_settings
  pattern from #1227
- tab_tlg.R: whitespace-only, keep main's formatting

Co-authored-by: Ona <no-reply@ona.com>
- Remove @importFrom logger log_info from imports-shiny.R and
  NAMESPACE (logger is no longer used, log_info is now in logging.R)
- Remove logger from DESCRIPTION Suggests (no remaining references)
- Remove dead observeEvent(study_types_list()) block from
  parameter_selection.R that referenced the old sub-module approach
  (param_selector_panel_server) which no longer exists in main
- Replace with debounced observer on selections_state() compatible
  with main's matrix-based parameter selection UI
- Update session_log.Rmd to remove DEBUG parameter list entry

Co-authored-by: Ona <no-reply@ona.com>
Resolve general_exclusions.R conflict: main refactored inline remove
observers into shared .register_remove_observers() helper, branch added
log_info() calls. Resolution: use main's shared helper with a new
on_remove callback parameter to preserve the branch's removal logging.
Auto-merged: DESCRIPTION, utils-exclusions.R, pkgdown/_pkgdown.yml.

Co-authored-by: Ona <no-reply@ona.com>
…g the log message to the current

 remote-tracking branch 'origin/main' into 1210-enhancement/replace-logger-with-console
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