Skip to contents

R6 Class providing queued logging functionality for Shiny survey applications using the main application's database connection pool.

Details

The logger uses a queue-based approach where messages are:

  1. Added to an in-memory queue immediately

  2. Displayed in the console (if not suppressed)

  3. Periodically processed and written to the database in batches

Features:

  • Uses main application pool for database operations

  • Efficient batch database writes

  • Immediate console feedback with color coding

  • Connection pool health monitoring

Message Types

  • INFO: Regular informational messages (green)

  • WARN: Warning messages (yellow)

  • ERROR: Error messages (red)

Public fields

log_table

Character string specifying the PostgreSQL table for logs

session_id

Character string containing unique session identifier

survey_name

Character string identifying the current survey

suppress_logs

Logical flag to suppress console output

queue

data.frame containing queued messages for batch processing

Methods


Method new()

Initialize a new survey logger instance

Usage

survey_logger$new(log_table, session_id, survey_name, suppress_logs = FALSE)

Arguments

log_table

Character string specifying logging table name

session_id

Character string containing session identifier

survey_name

Character string identifying the survey

suppress_logs

Logical flag to suppress console output. Default: FALSE


Method log_message()

Queue a message for logging and display in console

Usage

survey_logger$log_message(message, type = "INFO", zone = "DEFAULT")

Arguments

message

Character string containing message to log

type

Character string specifying message type (INFO/WARN/ERROR)

zone

Character string identifying logging zone. Default: "DEFAULT"

Returns

Invisible NULL


Method clone()

The objects of this class are cloneable with this method.

Usage

survey_logger$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.