Chechy Levas
Chechy Levas

Reputation: 2312

How to log from a future worker?

I would like to log to console from a worker created using the future package. However, logs from workers go into the void.

For example

library(future)
library(logger)
plan(multisession)
worker_function <- function() {
  log_info("Hello from a worker!")
  1
}
x <- future_map(1:2, ~ worker_function())
x

Running the above does not show any logs.

I found an issue that seems to be relevant (https://github.com/futureverse/future/issues/306) but not seem to offer a solution.

As a work around I can collect logs from workers and then log them when the main "thread" returns, but this is inconvenient. Any better way?

Upvotes: 0

Views: 39

Answers (0)

Related Questions