daroczig/logger

Calling `logger::log_{appender, threshold, layout, formatter}` functions via `do.call` fails

averissimo opened this issue · 1 comments

Found an edge case when testing a package against the master branch of this repository.

It works fine with current release v0.2.2, but fails against master

testthat::test_that("logger::log_appender `do.call` works the same as calling function", {
  t <- withr::local_tempfile()

  old_appender <- log_appender()

  do.call(
    logger::log_appender,
    list(
      logger::appender_file(t)
    )
  ) |>
    testthat::expect_no_error()

  logger::log_info("42")

  testthat::expect_length(readLines(t), 1)

  log_appender(old_appender)
})

testthat::test_that("logger::log_threshold `do.call` works the same as calling function", {
  old_threshold <- logger::log_threshold()
  
  do.call(
    logger::log_threshold, 
    list(
      logger::WARN
    )
  ) |> 
    testthat::expect_no_error()
  
  logger::log_info("42")
  
  logger::log_threshold(old_threshold)
})

Thanks for reporting this! Could you please check if #125 solves the problem? Would appreciate a review on the PR.