From bc06e8c6e357324751fc7990d52d0737612190ac Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Wed, 28 Nov 2018 11:29:55 -0500 Subject: [PATCH] Print real-time messages and warnings to console_log_file Warnings and messages are still printed to the console in bulk after each target is completed. Fixes #588. --- R/handlers.R | 9 ++++----- R/run.R | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/handlers.R b/R/handlers.R index ddb5a3cc2..6a429a583 100644 --- a/R/handlers.R +++ b/R/handlers.R @@ -3,18 +3,17 @@ handle_build_exceptions <- function(target, meta, config) { warn_opt <- max(1, getOption("warn")) withr::with_options( new = list(warn = warn_opt), - drake_warning( + warning( "target ", target, " warnings:\n", multiline_message(meta$warnings), - config = config + call. = FALSE ) ) } if (length(meta$messages) && config$verbose) { - drake_message( + message( "Target ", target, " messages:\n", - multiline_message(meta$messages), - config = config + multiline_message(meta$messages) ) } if (inherits(meta$error, "error")) { diff --git a/R/run.R b/R/run.R index d6dd8fd66..7b0139fc7 100644 --- a/R/run.R +++ b/R/run.R @@ -23,10 +23,12 @@ with_handling <- function(target, meta, config) { withCallingHandlers( value <- with_call_stack(target = target, config = config), warning = function(w) { + drake_log_warning(w$message, config = config) warnings <<- c(warnings, w$message) }, message = function(m) { msg <- gsub(pattern = "\n$", replacement = "", x = m$message) + drake_log_message(msg, config = config) messages <<- c(messages, msg) } ),