'logging'包的R命名空间问题

时间:2014-09-30 19:18:18

标签: r logging namespaces packages rstudio

我正在编写一个使用the logging package from CRAN的R包。在我的代码中,我在加载包时初始化日志记录:

#' @importFrom logging basicConfig
.onAttach <- function(libname, pkgname) {
  logging::basicConfig()
}

#' @importFrom logging setLevel
#' @export
setLogLevel <- function(level) {
  setLevel(level)
}

在我的DESCRIPTION文件中,我声明了依赖:

Depends:
    R (>= 3.0.2),
    Rcpp (>= 0.11.2)
Imports:
    FNN,
    plyr,
    geosphere,
    logging

然而,它看起来像R CMD check(我通过&#34; Check Package&#34;在RStudio中调用)并不喜欢名称空间:

* checking whether the package can be loaded with stated dependencies ... WARNING
Loading required package: Rcpp
Error : .onAttach failed in attachNamespace() for ‘ABC’, details:
  call: UseMethod("updateOptions")
  error: no applicable method for ‘updateOptions’ applied to an object of class "Logger"
Error: package or namespace load failed for ‘ABC’
Execution halted

It looks like this package (or one of its dependent packages) has an
unstated dependence on a standard package.  All dependencies must be
declared in DESCRIPTION.
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.

...

* checking for missing documentation entries ... ERROR
Error: package or namespace load failed for ‘ABC’
Call sequence:
2: stop(gettextf("package or namespace load failed for %s", sQuote(package)), 
       call. = FALSE, domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE)
Execution halted

Exited with status 1.

它抱怨的updateOptions()方法是我在初始化时调用的logging::basicConfig()函数的一部分:

> logging::basicConfig
function (level = 20) 
{
    rootLogger <- getLogger()
    updateOptions(rootLogger, level = namedLevel(level))
    rootLogger$addHandler("basic.stdout", writeToConsole, level = namedLevel(level))
    invisible()
}
<environment: namespace:logging>

d> logging::updateOptions
function (container, ...) 
UseMethod("updateOptions")
<environment: namespace:logging>

感谢任何人提供的任何见解。

0 个答案:

没有答案