daroczig / daroczig/logger

Feature request: turn off `log_messages` temporarily

Open
#235 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
323
Forks
46
Avg merge
1d 21h
Merged PRs (30d)
1

Description

I am using the {logger} together with the {progress} package.
It's very helpful to have `log_messages()` at the top of my script.
However, when my script gets to the long-running for-loop, I'd like to be able to print the progress bar to the terminal without having the progress bar updates print to the log.

I'm asking to be able to do something like this:

```r
# top of script
library(progress)
library(logger)
log_messages(TRUE)

# lots of code goes here
message("I'm a little teapot") # this line should appear in the logs

# long-running for loop
pb = progress::progress_bar$new(total = 100)
log_info("Starting long loop now")
log_messages(FALSE)
for (i in 1:100) {
pb$tick() # should print to terminal, but not appear in logs
# complex code goes here
Sys.sleep(0.1)
}
log_info("Finished long looop")
# turn message logging back on
log_messages(TRUE)

# rest of script continues
message("Tada") # this line should appear in logs

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.