Skip to contents

Attaches an R task callback that silently logs every top-level expression evaluated in the session, together with its status (OK / ERR), timestamp, and working directory. ggplot2 figures are auto-saved as PNGs whenever a new plot is detected; base-R graphics are captured on plot.new.

Usage

start_session_logger(log_root = NULL, quiet = FALSE)

Arguments

log_root

Character. Parent directory for log files. Defaults to ~/.R/session_logs.

quiet

Logical. If FALSE (default) prints a startup message showing the log file path.

Value

Invisibly returns the path to the log file.

Details

Logs are written to <log_root>/<session_id>_session.log and plots to <log_root>/<session_id>_plots/. Call summarize_r_session() afterwards to generate a markdown report and a clean reconstructed R script.

Recommended usage: add the following line to your ~/.Rprofile so the logger starts automatically in every new R session:

if (requireNamespace("scSidekick", quietly = TRUE)) scSidekick::start_session_logger()