Skip to content

Commit

Permalink
log_echo and debug are actually pretty similar (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored Jun 19, 2024
1 parent e8bd6f5 commit 8af29ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions R/eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ evaluate <- function(input,

out <- vector("list", nrow(parsed))
for (i in seq_along(out)) {
if (debug) {
message(parsed$src[[i]])
if (log_echo || debug) {
cat_line(parsed$src[[i]], file = stderr())
}

# if dev.off() was called, make sure to restore device to the one opened by
Expand All @@ -112,7 +112,6 @@ evaluate <- function(input,
use_try = stop_on_error != 2L,
keep_warning = keep_warning,
keep_message = keep_message,
log_echo = log_echo,
log_warning = log_warning,
output_handler = output_handler,
include_timing = include_timing
Expand Down Expand Up @@ -141,16 +140,11 @@ evaluate_top_level_expression <- function(exprs,
use_try = FALSE,
keep_warning = TRUE,
keep_message = TRUE,
log_echo = FALSE,
log_warning = FALSE,
output_handler = new_output_handler(),
include_timing = FALSE) {
stopifnot(is.expression(exprs))

if (log_echo && !is.null(src)) {
cat(src, "\n", sep = "", file = stderr())
}

source <- new_source(src, exprs[[1]], output_handler$source)
output <- list(source)

Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cat_line <- function(...) {
cat(paste0(..., "\n", collapse = ""))
cat_line <- function(..., file = stdout()) {
cat(paste0(..., "\n", collapse = ""), file = file)
}

indent <- function(x, by = " ", drop_trailing_nl = TRUE) {
Expand Down

0 comments on commit 8af29ec

Please sign in to comment.