Debugger {verifyr2} | R Documentation |
Debugger.R
Description
Debugger.R
Debugger.R
Details
Class for managing the library debugging. Tracks the debugged method execution times and prints out the full debugging information only when the main debugging instance is stopped.
Public fields
stack
local property for storing debugging labels and start times
Methods
Public methods
Method new()
Constructor for initializing the Debugger instance.
Usage
Debugger$new()
Method open_debug()
Method for opening new debug instance to the current debugging stack. Stores also the start time for execution time calculation.
Usage
Debugger$open_debug(label)
Arguments
label
debugging message
Method add_debug()
Method for adding a new debug string under the currently open debug instance.
Usage
Debugger$add_debug(label)
Arguments
label
debugging message
Method close_debug()
Method for closing a debug instance from the current debugging stack. If the stopped debug instance is the main level one, the whole debug data is printed out to console. If the stopped debug instance is not the main level one, calculates the execution time of current debug instance and updates the stack data.
Usage
Debugger$close_debug()
Method print_debug_tree()
Recursive method for printing out the current debug stack items and recursively all the item children. This method is called for the whole stack once the topmost debug instance is stopped.
Usage
Debugger$print_debug_tree(entry, depth = 0)
Arguments
entry
current debug level being processed for printing
depth
current processing depth for printing indentation
Method clone()
The objects of this class are cloneable with this method.
Usage
Debugger$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
# Creates a debugger instance.
debugger <- Debugger$new()
# Opening and closing debugs in multileveled function calls.
function1 <- function() {
debugger$open_debug("function1")
function2()
debuger$close_debug()
}
function2 <- function() {
debugger$open_debug("function2")
Sys.sleep(1)
debugger$close_debug()
}
# This will produce the following printout to the console after the
# function1 finishes
#
# - 'function1' (execution time 7 ms)
# - 'function2' (execution time 5 ms)