Structured, leveled logging and timers for pipeline observability.
This module contains the following functions:
set_log_enabled — Enable or disable loggingset_log_file — Set log file for dual outputset_log_level — Set log levellog_info — Log an INFO messagelog_debug — Log a DEBUG messagelog_warning — Log a WARNING messagelog_error — Log an ERROR messagelog_critical — Log a CRITICAL messagelog_section — Print a formatted section headerlog_subsection — Print a formatted subsection headerlog_progress — Log a progress indicatorlog_keyvalue — Log a key-value pairlog_stats — Print summary statisticslog_table — Print a formatted tabletimer_start — Start a timer for performance measurementtimer_stop — Stop a timer and log elapsed timeset_log_enabledEnable or disable logging
Usage:
set_log_enabled(enabled)
Arguments:
| Argument | Description |
|----------|-------------|
| enabled | Logical. |
Examples:
set_log_enabled(FALSE) # turn off all logging
set_log_fileSet log file for dual output
Usage:
set_log_file(filepath)
Arguments:
| Argument | Description |
|----------|-------------|
| filepath | Character. Path to log file. NULL to disable. |
Examples:
set_log_file("rclade.log")
set_log_levelSet log level
Usage:
set_log_level(level)
Arguments:
| Argument | Description |
|----------|-------------|
| level | Character. One of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". |
Examples:
set_log_level("DEBUG")
log_infoLog an INFO message
Usage:
log_info(..., .module = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| ... | Message components (passed to sprintf if multiple). |
| .module | Character. Optional module/function tag (§15). Default: NULL. |
Examples:
log_info("Starting processing", .module = "main")
log_debugLog a DEBUG message
Usage:
log_debug(..., .module = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| ... | Message components (passed to sprintf if multiple). |
| .module | Character. Optional module/function tag (§15). Default: NULL. |
Examples:
log_debug("variable x =", 42, .module = "parse")
log_warningLog a WARNING message
Usage:
log_warning(..., .module = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| ... | Message components (passed to sprintf if multiple). |
| .module | Character. Optional module/function tag (§15). Default: NULL. |
Examples:
log_warning("Clade not monophyletic, skipped", .module = "collapse")
log_errorLog an ERROR message
Usage:
log_error(..., .module = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| ... | Message components (passed to sprintf if multiple). |
| .module | Character. Optional module/function tag (§15). Default: NULL. |
Examples:
log_error("File not found", .module = "io")
log_criticalLog a CRITICAL message
Usage:
log_critical(..., .module = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| ... | Message components (passed to sprintf if multiple). |
| .module | Character. Optional module/function tag (§15). Default: NULL. |
Examples:
log_critical("Out of memory", .module = "main")
log_sectionPrint a formatted section header
Usage:
log_section(title)
Arguments:
| Argument | Description |
|----------|-------------|
| title | Character. Section title. |
Examples:
log_section("Stage 1: Reading data")
log_subsectionPrint a formatted subsection header
Usage:
log_subsection(title)
Arguments:
| Argument | Description |
|----------|-------------|
| title | Character. Subsection title. |
Examples:
log_subsection("Sub-step: parsing labels")
log_progressLog a progress indicator
Usage:
log_progress(current, total, item = "")
Arguments:
| Argument | Description |
|----------|-------------|
| current | Integer. Current progress. |
| total | Integer. Total items. |
| item | Character. Description of current item. |
Examples:
log_progress(3, 10, item = "Processing tree file")
log_keyvalueLog a key-value pair
Usage:
log_keyvalue(key, value, level = "INFO")
Arguments:
| Argument | Description |
|----------|-------------|
| key | Character. Key name. |
| value | Any. Value to display. |
| level | Character. Log level. Default: "INFO". |
Examples:
log_keyvalue("Number of nodes", 1234)
log_statsPrint summary statistics
Usage:
log_stats(stats)
Arguments:
| Argument | Description |
|----------|-------------|
| stats | Named list of statistics. |
Examples:
log_stats(list(files = 5, tips = 120))
log_tablePrint a formatted table
Usage:
log_table(data, title = NULL)
Arguments:
| Argument | Description |
|----------|-------------|
| data | Named list or data.frame to display. |
| title | Character. Optional table title. |
Examples:
log_table(data.frame(a = 1:3, b = letters[1:3]),
title = "Statistics")
timer_startStart a timer for performance measurement
Usage:
timer_start(name)
Arguments:
| Argument | Description |
|----------|-------------|
| name | Character. Timer name. |
Examples:
timer_start("pipeline")
timer_stopStop a timer and log elapsed time
Usage:
timer_stop(name, level = "INFO")
Arguments:
| Argument | Description |
|----------|-------------|
| name | Character. Timer name. |
| level | Character. Log level. Default: "INFO". |
Value:
Numeric. Elapsed seconds.
Examples:
timer_stop("pipeline")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.