daroczig / logger

A lightweight, modern and flexible, log4j and futile.logger inspired logging utility for R
https://daroczig.github.io/logger
280 stars 41 forks source link

ERROR: package 'global' not found #89

Closed natdring closed 6 months ago

natdring commented 2 years ago

Whenever the log_layout() function is called, the formatting of my log messages works correctly, but there is an issue with ERROR: package 'global' not found being thrown. The error does not appear if log_layout() isn't called.

Any ideas what is causing this? I could not find any reference to this issue or anything similar.

Here is my logger setup:


library(logger)
library(slackr)

with_log_threshold({
  log_errors()
  # log_warnings()
  # log_messages()
}, threshold = ERROR)

.log.cmd     <- R.utils::commandArgs(asValues=TRUE)
.log.level   <- kl.settings$log_level
.log.env     <- kl.settings$env_key
.log.script  <- .log.cmd$file
.log.args    <- paste(commandArgs(trailingOnly=TRUE), collapse=' ')
if(is.null(.log.script)) .log.script = 'R'
.log.command <- paste(.log.script, .log.args, collapse=' ')

#get_logger_meta_variables()
.log.format <- layout_glue_generator(format = '{time} ({.log.env}) {.log.command} [{pid}] {level}: {msg}')

log_formatter(formatter_glue)

log_threshold(.log.level)
log_layout(.log.format) # This line causes the 'global' package error
log_appender(appender_file(kl.settings$log_file))

if (kl.settings$log_to_slack) {
  log_threshold(.log.level, index=2)
  log_layout(.log.format, index=2) # This line causes the 'global' package error
  # if (!exists('.slack.initialized')) source('include/slack.R')
  slackr_setup(echo=F)
  log_appender(appender_slack(channel=kl.settings$slack_channel_logs), index=2)
}
daroczig commented 2 years ago

Can you please post a minimal reproducible example and your sessionInfo()?

daroczig commented 6 months ago

I cannot reproduce the problem, and did not hear back, so closing. Please reopen with more info as per above.