trace_package {toscutil} | R Documentation |
Traces function calls from a package
Description
Traces all function calls from a package and writes them to file
with timestamps and callstack depth. Should always be used in combination with untrace_package()
to untrace the package after use. For example trace_package("graphics"); on.exit(untrace_package("graphics")
. See examples for more details.
Usage
trace_package(
pkg,
file = stdout(),
max = Inf,
funign = character(),
opsign = TRUE,
dotign = TRUE,
silent = TRUE,
exitmsg = "exit"
)
Arguments
pkg |
Package name to trace. |
file |
File to write to. |
max |
Maximum depth of callstack to print. |
funign |
Functions to ignore. |
opsign |
Whether to ignore operators. |
dotign |
Whether to ignore functions starting with a dot. |
silent |
Whether to suppress messages. |
exitmsg |
Message to print on function exits. |
Details
Some function define their own on.exit()
handlers with option add = FALSE
. For those functions, exit tracing is impossible (as described in trace()
). For now those functions have to be detected and ignored manually by the user using argument funign
.
Value
No return value, called for side effects
See Also
Examples
## Not run:
# Trace all function from the graphics package, except for `plot.default`
# as it defines its own on.exit() handler, i.e. exit tracing is impossible.
local({
trace_package("graphics", funign = "plot.default")
on.exit(untrace_package("graphics"), add = TRUE)
plot(1:10)
})
## End(Not run)