Skip to content

Fix log with separator environment - #245

Merged
daroczig merged 3 commits into
daroczig:mainfrom
mrcaseb:fix-log-with-separator-environment
Sep 9, 2026
Merged

daroczig merged 3 commits into
daroczig:mainfrom
mrcaseb:fix-log-with-separator-environment

Conversation

@mrcaseb

@mrcaseb mrcaseb commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

fixes #244

As described in the linked issue, log_with_separator failed to evaluate expressions when called from inside a function.

Using the reprex from the issue, this is now working as expected

library(logger)
log_appender(appender_stdout)
logger_fct3 <- function(arg){
  log_info("Argumet says {arg}")
  log_with_separator("Argument says {arg}.")
}
arg <- "Hello World"
logger_fct3("This is something else")
#> INFO [2026-09-07 17:05:04] Argumet says This is something else
#> INFO [2026-09-07 17:05:04] =====================================================
#> INFO [2026-09-07 17:05:04] = Argument says This is something else.             =
#> INFO [2026-09-07 17:05:04] =====================================================

I'll be honest: I don't know why adding envir = parent.frame() to the do.call call did the trick because it's the default value of the envir argument. But it's definitely working now.

I didn't add a news bullet because I am not sure how you would like to handle development versions. I can add a call to usethis::use_dev_version() if you want me to.

I also added a test for this exact issue. I kept the logic using expect_output although I think this should be a snapshot.

@daroczig

daroczig commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Thanks a ton!

Could you please bump the version by appending .9000 and add a news item at the top with "development version" instead of an exact date like it was (un)done at a9b4180?

@daroczig
daroczig merged commit 3c3f3aa into daroczig:main Sep 9, 2026
14 checks passed
@daroczig

daroczig commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Fantastic, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log_with_separator fails to evaluate glue expression when called from inside another function

2 participants