Skip to content

Commit

Permalink
make sure there are no unknown named arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed Feb 28, 2024
1 parent ec619ce commit f0a9c35
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions R/logger.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,32 +311,47 @@ validate_log_level <- function(level) {
}


#' Make sure there are no unknown named arguments
#' @keywords internal
assert_no_unknown_args <- function() {
call <- match.call(definition = sys.function(1), call = sys.call(1), expand.dots = FALSE)
stopifnot("Unknown named argument provided." = is.null(names(call$`...`)))
}


#' @export
log_fatal <- function(...) {
assert_no_unknown_args()
log_level(FATAL, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_error <- function(...) {
assert_no_unknown_args()
log_level(ERROR, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_warn <- function(...) {
assert_no_unknown_args()
log_level(WARN, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_success <- function(...) {
assert_no_unknown_args()
log_level(SUCCESS, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_info <- function(...) {
assert_no_unknown_args()
log_level(INFO, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_debug <- function(...) {
assert_no_unknown_args()
log_level(DEBUG, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}
#' @export
log_trace <- function(...) {
assert_no_unknown_args()
log_level(TRACE, ..., .logcall = sys.call(), .topcall = sys.call(-1), .topenv = parent.frame())
}

Expand Down

0 comments on commit f0a9c35

Please sign in to comment.