Skip to content

Commit

Permalink
Print real-time messages and warnings to console_log_file
Browse files Browse the repository at this point in the history
Warnings and messages are still printed to
the console in bulk after each target is completed.
Fixes #588.
  • Loading branch information
wlandau-lilly committed Nov 28, 2018
1 parent 5df5ded commit bc06e8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions R/handlers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 2 additions & 0 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
),
Expand Down

0 comments on commit bc06e8c

Please sign in to comment.