Description Usage Arguments Details Value See Also Examples
Track time of code execution in easy, efficient and nice looking way
1 2 3 | log_time(message, level = 'DEBUG') %<% {
expression
}
|
message |
A string describing context of code. Can't be empty. |
level |
A logging level. One of 'DEBUG', 'INFO', 'WARNING', 'ERROR'. Default is DEBUG. |
log_time
has special call that requires using pipe operator %<%
.
log_time
can handle nested calls and returns execution times of nested parts as well as overall execution time.
Besides, it makes script much more organized and readable.
By default, log_time
will print messages to console. This can be overwritten by configure_logging
or, if used inside logger context, by create_logger
function.
Start and End messages. Execution time is appended to the End message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # create a logtime with message 'Some text';
# default level is DEBUG
log_time('Some text') %<% {
Sys.sleep(1)
}
# output:
# 2016-09-21 10:54:31 - DEBUG - [Start] - [Some text]
# 2016-09-21 10:54:32 - DEBUG - [End ] - [Some text] - [Done in 1 sec. (0 min.)]
# create the same logtime with changed level to INFO
log_time('Some text', level = 'INFO') %<% {
Sys.sleep(1)
}
# output:
# 2016-09-21 10:53:20 - INFO - [Start] - [Some text]
# 2016-09-21 10:53:21 - INFO - [End ] - [Some text] - [Done in 1 sec. (0 min.)]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.