auditTrail: Log Audit Trail.

View source: R/auditTrail.R

auditTrailR Documentation

Log Audit Trail.

Description

Adds an audit trail to a dataset.

Usage

auditTrail(
  obj,
  f.call = NULL,
  key = NULL,
  value = NULL,
  label = NULL,
  arguments = TRUE,
  exact = TRUE,
  remove = FALSE,
  package = NULL,
  rversion = TRUE,
  timestamp = TRUE
)

Arguments

obj

object to add or update the audit trail.

f.call

the function call i.e. match.call().

key

list or vector of additional keys to log.

value

list or vector of additional values to log.

label

optional label used if f.call=NULL.

arguments

logical. TRUE log function arguments.

exact

logical for exact matching of attribute name.

remove

logical. If TRUE the 'audit trail' attribute is removed.

package

character to log the package version.

rversion

logical to log the R version.

timestamp

logical to add or update timestamp.

Details

Automatically add or updates an attribute 'audit trail' with arguments and parameters extracted from the function call. To list the arguments with the default set but not overridden arguments=TRUE must be set (default). Additional custom key-value pairs can be added. The label is extracted from the function name from f.call. Specify package to include the version number of a package.

Value

object with added or updated attribute 'audit trail'.

Examples

# A simple function with audit trail logging.
myFunction <- function(x, a, b = 5) {
  x <- x + a + b
  x <- auditTrail(obj = x, f.call = match.call(), package = "strvalidator")
  return(x)
}
# Run the function.
myData <- myFunction(x = 10, a = 2)
# Check the audit trail.
cat(attr(myData, "audit trail"))

# Remove the audit trail.
myData <- auditTrail(myData, remove = TRUE)
# Confirm that the audit trail is removed.
cat(attr(myData, "audit trail"))

strvalidator documentation built on July 26, 2023, 5:45 p.m.