| logEvent | R Documentation |
This is one of the more complex integration of services into the 'redcapAPI“ package. It's purpose is to provide the ability for a system administrator (or user) to integrate logging into a report or application. The ability to inject a logging framework without a developer's code being altered.
logEvent(severity, ...)
createSplunkFUN(
token = Sys.getenv("SPLUNK_TOKEN"),
url = Sys.getenv("SPLUNK_URL"),
project = Sys.getenv("SPLUNK_PROJECT"),
allowDebug = FALSE
)
logWarning(...)
logStop(...)
logMessage(...)
severity |
|
... |
Information to include in the log event. Each argument must have a name. |
token |
|
url |
|
project |
|
allowDebug |
|
To do this the callback function is pulled from the option redcapAPI_logger
which defaults to doing nothing.
When the package starts up, it checks to see if SPLUNK_TOKEN and SPLUNK_URL
ENV variables are set and if so, it automatically redirects the
redcapAPI_logger to point at Splunk. It will also use SPLUNK_PROJECT
if defined, otherwise the project will be the directory name that the
code is executing from.
There are also two helper functions logWarning and logStop which
will call logging if enabled first, then warn or stop as requested.
The function createSplunkFUN will create a SPLUNK logger callback function. It will pull 'SPLUNK_TOKEN', 'SPLUNK_URL' and 'SPLUNK_PROJECT' from ENV if the corresponding arguments are not specified.
## Not run:
options(redcapAPI_logger=function(severity, ...) {cat(severity, ' ', dput(list(...)), '\n')})
logEvent("INFO", "This is a logged event")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.