Skip to contents

Serialises log entries to CSV or JSON, with optional date filtering. Use signed = TRUE to run chain verification and stamp the integrity result into the export — useful for handoffs, audits, or archival.

Usage

export_audit_trail(
  log,
  format = c("csv", "json"),
  from = NULL,
  to = NULL,
  path = NULL,
  signed = FALSE,
  include_genesis = FALSE
)

Arguments

log

A regulog object or a path to a .rlog file.

format

Character. "csv" or "json".

from

Character or NULL. Include entries on or after this date (ISO-8601, e.g. "2026-01-01").

to

Character or NULL. Include entries on or before this date.

path

Character or NULL. Output file path. If NULL, returns the data without writing to disk.

signed

Logical. If TRUE, verify the chain and include chain_intact and verified_at fields in the export.

include_genesis

Logical. Include the genesis record. Default FALSE.

Value

A data frame (CSV) or list (JSON), invisibly.

Details

CSV column layout

ColumnDescription
entry_idMonotone sequence number
timestampISO-8601 UTC
appApplication name
app_versionApplication version
userActing user identity
typeACTION, CHANGE, NOTE, or SIGNATURE
actionAction label (ACTION entries)
objectTarget of the action or change
fieldField name (CHANGE entries)
beforePrior value (CHANGE entries)
afterNew value (CHANGE and SIGNATURE entries)
reasonJustification (ACTION, CHANGE, NOTE entries)
textFree-text annotation (NOTE entries)
meaningSignature meaning (SIGNATURE entries)
entry_hashSHA-256 of this entry
prev_hashSHA-256 of prior entry
chain_intactTRUE/FALSE (signed exports only)
verified_atISO-8601 UTC of export (signed exports only)

Examples

log <- regulog_init(app = "my-app", user = "jsmith")
log_action(log,
  action = "approved",
  object = "model_v3",
  reason = "Metrics passed threshold"
)
#> regulog: logged action 'approved' on 'model_v3'
df <- export_audit_trail(log, format = "csv")

# \donttest{
export_audit_trail(log,
  format = "csv",
  from   = "2026-01-01",
  signed = TRUE,
  path   = tempfile(fileext = ".csv")
)
#> regulog: exported 1 row(s) to /tmp/RtmpxW8xNs/file19fc3b6669b.csv
# }