Skip to content

feat: add log-points for NCA user input changes#1221

Draft
Gero1999 wants to merge 13 commits into1210-enhancement/replace-logger-with-consolefrom
1219-enhancement/nca-input-log-points
Draft

feat: add log-points for NCA user input changes#1221
Gero1999 wants to merge 13 commits into1210-enhancement/replace-logger-with-consolefrom
1219-enhancement/nca-input-log-points

Conversation

@Gero1999
Copy link
Copy Markdown
Collaborator

@Gero1999 Gero1999 commented Apr 14, 2026

Issue

Closes #1219

Description

Adds INFO-level logging for user input changes across the NCA setup modules so that exported session_log.txt files capture what configuration choices the user made — not just that a calculation happened.

New log-points added:

  • Settings — analyte, specimen, profile, extrapolation method, min half-life points, flag rule enable/disable and threshold changes
  • Data Imputation — BLQ strategy changes, C0 imputation toggle
  • Parameter Selection — full parameter list at DEBUG level (count was already logged at INFO)
  • Slope Selector — rule add/remove upgraded from TRACE→INFO, DEBUG summary of rule counts on table change
  • General Exclusions — exclusion add (with row count, type, reason), removal, settings restore

Definition of Done

  • Log messages appear in the R console when users change NCA settings, parameters, slope rules, or exclusions
  • Messages are included in the ZIP-exported session_log.txt
  • No logging on reactive invalidation noise — only meaningful user actions

How to test

  1. Run aNCA::run_app()
  2. Upload data and navigate to the NCA tab
  3. Change settings (method, analyte, specimen, flag rules, etc.)
  4. Add/remove slope rules and exclusions
  5. Verify log messages appear in the R console for each action
  6. Export ZIP and check session_log.txt contains the entries

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

This PR targets 1210-enhancement/replace-logger-with-console (#1212), not main. It will auto-retarget to main once #1212 is merged.

All log calls use the same log_info/log_debug functions introduced in #1212 — no new dependencies.

Version bump and NEWS entry still needed before merge.

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 Gero1999 marked this pull request as ready for review April 14, 2026 13:00
@Gero1999 Gero1999 marked this pull request as draft April 14, 2026 13:01
Gero1999 and others added 7 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>
@Gero1999 Gero1999 force-pushed the 1219-enhancement/nca-input-log-points branch from 91ca90b to 893084b Compare April 14, 2026 15:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds INFO/DEBUG logging across the Shiny NCA setup modules so exported session_log.txt captures user configuration changes (settings, imputation, parameter selection, slope rules, exclusions), improving post-hoc traceability of an NCA run.

Changes:

  • Added log points for selection changes (analyte/specimen/profile, extrapolation method, min half-life points, flag rules).
  • Added log points for BLQ and C0 imputation setting changes.
  • Added more detailed logging for slope rule and exclusion add/remove/restore actions, plus DEBUG summaries.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
inst/shiny/modules/tab_nca/setup/slope_selector.R Adds DEBUG summary log when manual slope rules table updates.
inst/shiny/modules/tab_nca/setup/settings.R Adds INFO logs for key NCA settings and flag-rule changes.
inst/shiny/modules/tab_nca/setup/parameter_selection.R Adds DEBUG log listing selected parameters per study type.
inst/shiny/modules/tab_nca/setup/manual_slopes_table.R Upgrades add/remove slope rule logs from TRACE to INFO.
inst/shiny/modules/tab_nca/setup/general_exclusions.R Adds INFO logs for exclusions restored/added/removed.
inst/shiny/modules/tab_nca/setup/data_imputation.R Adds INFO logs for BLQ strategy and C0 imputation toggle changes.

Comment on lines +291 to +293
if (length(target_profile) > 0 && !anyNA(target_profile)) {
log_info("NCA profile selection changed: ", paste(target_profile, collapse = ", "))
}
Comment on lines 303 to +307
if (updating_filters()) return()
updating_filters(TRUE)
on.exit(updating_filters(FALSE))

log_info("Analyte selection changed: ", paste(input$select_analyte, collapse = ", "))
Comment on lines 339 to +343
if (updating_filters()) return()
updating_filters(TRUE)
on.exit(updating_filters(FALSE))

log_info("Specimen selection changed: ", paste(input$select_pcspec, collapse = ", "))
Comment on lines +160 to 177
rows_sel <- getReactableState("conc_table-table", "selected")
reason <- input$exclusion_reason
nca_checked <- isTRUE(input$cb_manual_nca)
tlg_checked <- isTRUE(input$cb_tlg)

if (length(rows_sel) > 0 && nzchar(reason) && (nca_checked || tlg_checked)) {
type_label <- if (nca_checked && tlg_checked) "NCA + TLG"
else if (nca_checked) "NCA"
else "TLG"
log_info(
"Exclusion added: ", length(rows_sel), " rows, type=", type_label,
", reason='", reason, "'"
)
}

.handle_add_exclusion(
input, session, exclusion_list, xbtn_counter
)
# Add a new row to the table when the user clicks the add button
observeEvent(input$add_rule, {
log_trace("{id}: adding manual slopes row")
log_info("Slope selector: adding manual slope rule")
# Remove selected rows from the table when the user clicks the remove button
observeEvent(input$remove_rule, {
log_trace("{id}: removing manual slopes row")
log_info("Slope selector: removing manual slope rule")
n_rules <- nrow(manual_slopes())
n_excl <- sum(manual_slopes()$TYPE == "Exclusion", na.rm = TRUE)
n_incl <- n_rules - n_excl
log_debug("Slope rules updated: ", n_rules, " total (", n_incl, " inclusions, ", n_excl, " exclusions)")
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.

2 participants