Title: | Echo Code Evaluations |
---|---|
Description: | Capture code evaluations and script executions by expressions, outputs, and condition calls for logging. |
Authors: | Jordan Mark Barbone [aut, cph, cre] |
Maintainer: | Jordan Mark Barbone <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0.9000 |
Built: | 2024-11-16 03:33:22 UTC |
Source: | https://github.com/jmbarbone/echo |
Echo expression or a file
echo( expr, log = echo_get_log(), msg = echo_get_msg(), level = echo_get_level(), file = NULL )
echo( expr, log = echo_get_log(), msg = echo_get_msg(), level = echo_get_level(), file = NULL )
expr |
Expression to evaluate; should be written with curly braces (see examples) |
log |
A connection or file name for outputs; defaults to |
msg |
Logical, if |
level |
Sets the echo level (see details); defaults to |
file |
File path to evaluate (like |
Levels of output can be controlled with level
:
0
EXP
: logs expressions that were evaluated
1
OUT
: logs outputs from expressions
2
MSG
: logs messages
3
WRN
: logs warnings
4
ERR
: logs errors
When set, all outputs at the level
or below are run. Errors are always
logged as they will interrupt and stop the program.
Timestamps are printed in UTC by default. To control this, set the option
value, such as options(echo.timezone = "EST")
.
Nothing, called for side-effects
# make sure to use braces for expr echo(letters, level = 0) # bad echo({letters}, level = 0) # good try(echo( expr = { print(1 + 1) Sys.sleep(2) head(mtcars) message(1) warning(2) stop(3) }, level = 0 )) # Parse lines in a file instead try(echo(file = system.file("example-script.R", package = "echo"))) # Note that x <- c("example for", "writing lines") echo({ x print(x) writeLines(x) }, level = 0)
# make sure to use braces for expr echo(letters, level = 0) # bad echo({letters}, level = 0) # good try(echo( expr = { print(1 + 1) Sys.sleep(2) head(mtcars) message(1) warning(2) stop(3) }, level = 0 )) # Parse lines in a file instead try(echo(file = system.file("example-script.R", package = "echo"))) # Note that x <- c("example for", "writing lines") echo({ x print(x) writeLines(x) }, level = 0)