Skip to content

Commit

Permalink
Evaluate arguments only if they are to be logged
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefhajnala committed Jul 23, 2019
1 parent f9bff45 commit 77afd3f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/logger.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ log_level <- function(level, ..., namespace = NA_character_,
for (definition in definitions) {

log_fun <- do.call(logger, definition)
log_arg <- list(...)
log_arg <- list()

log_arg$level <- validate_log_level(level)
log_arg$.logcall <- .logcall
Expand All @@ -290,7 +290,9 @@ log_level <- function(level, ..., namespace = NA_character_,
log_arg$namespace <- namespace

## TODO try with match.call and replace [[1]]?
do.call(log_fun, log_arg)
if (log_arg$level <= get("threshold", envir = environment(log_fun))) {
do.call(log_fun, c(list(...), log_arg))
}

}
}
Expand Down

0 comments on commit 77afd3f

Please sign in to comment.