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
regulogobject or a path to a.rlogfile.- 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. IfNULL, returns the data without writing to disk.- signed
Logical. If
TRUE, verify the chain and includechain_intactandverified_atfields in the export.- include_genesis
Logical. Include the genesis record. Default
FALSE.
Details
CSV column layout
| Column | Description |
entry_id | Monotone sequence number |
timestamp | ISO-8601 UTC |
app | Application name |
app_version | Application version |
user | Acting user identity |
type | ACTION, CHANGE, NOTE, or SIGNATURE |
action | Action label (ACTION entries) |
object | Target of the action or change |
field | Field name (CHANGE entries) |
before | Prior value (CHANGE entries) |
after | New value (CHANGE and SIGNATURE entries) |
reason | Justification (ACTION, CHANGE, NOTE entries) |
text | Free-text annotation (NOTE entries) |
meaning | Signature meaning (SIGNATURE entries) |
entry_hash | SHA-256 of this entry |
prev_hash | SHA-256 of prior entry |
chain_intact | TRUE/FALSE (signed exports only) |
verified_at | ISO-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
# }
