Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logger error All unnamed arguments must be length 1. #103

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/register_handlers.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ parse_logger_message <- function(m) {
if (type %in% c("error", "warning") && !is.null(m$call)) {
msg <- sprintf("In %s: %s", sQuote(paste0(format(m$call), collapse = "")), msg)
}
return(msg)
return(paste(msg, collapse = "\n"))
}

register_handlers_possible <- function() {
Expand Down
16 changes: 11 additions & 5 deletions tests/testthat/test-register_handlers.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
testthat::test_that("parse_logger_message correctly works on condition object", {
testthat::expect_identical(parse_logger_message(simpleMessage("foo")), "foo")
testthat::expect_identical(parse_logger_message(simpleWarning("foo")), "foo")
testthat::expect_identical(parse_logger_message(simpleError("foo")), "foo")
testthat::expect_identical(parse_logger_message(simpleMessage(message = "foo")), "foo")
testthat::expect_identical(parse_logger_message(simpleWarning(message = "foo")), "foo")
testthat::expect_identical(parse_logger_message(simpleError(message = "foo")), "foo")
})

testthat::test_that("parse_logger_message concatenates n-element message", {
testthat::expect_identical(parse_logger_message(simpleMessage(message = c("foo1", "foo2"))), "foo1\nfoo2")
testthat::expect_identical(parse_logger_message(simpleWarning(message = c("foo1", "foo2"))), "foo1\nfoo2")
testthat::expect_identical(parse_logger_message(simpleError(message = c("foo1", "foo2"))), "foo1\nfoo2")
})

testthat::test_that("parse_logger_message includes call on warnings and errors", {
testthat::expect_match(parse_logger_message(simpleWarning("foo", "bar")), "In .bar.: foo")
testthat::expect_match(parse_logger_message(simpleError("foo", "bar")), "In .bar.: foo")
testthat::expect_match(parse_logger_message(simpleWarning(message = "foo", call = "bar")), "In .bar.: foo")
testthat::expect_match(parse_logger_message(simpleError(message = "foo", call = "bar")), "In .bar.: foo")
})

testthat::test_that("parse_logger_message throws if not supported class of argument", {
Expand Down
Loading