auditTrail {strvalidator} | R 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. |
key |
list or vector of additional keys to log. |
value |
list or vector of additional values to log. |
label |
optional label used if |
arguments |
logical. |
exact |
logical for exact matching of attribute name. |
remove |
logical. If |
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"))