R 向复杂函数添加日志记录?

R 向复杂函数添加日志记录?,r,debugging,logging,R,Debugging,Logging,假设我有一个(至少主观上)复杂的函数,如下所示: library(rgithub) pull <- function(i){ commits <- get.pull.request.commits(owner = owner, repo = repo, id = i, ctx = get.github.context(), per_page=100) links <- digest_header_links(commits) number_of_pages <-

假设我有一个(至少主观上)复杂的函数,如下所示:

library(rgithub)

pull <- function(i){
 commits <- get.pull.request.commits(owner = owner, repo = repo, id = i, ctx = get.github.context(), per_page=100)
 links <- digest_header_links(commits)
 number_of_pages <- links[2,]$page
 if (number_of_pages != 0)
   try_default(for (n in 1:number_of_pages){
    if (as.integer(commits$headers$`x-ratelimit-remaining`) < 5)
     Sys.sleep(as.integer(commits$headers$`x-ratelimit-reset`)-    as.POSIXct(Sys.time()) %>% as.integer())
  else
    get.pull.request.commits(owner = owner, repo = repo, id = i, ctx = get.github.context(), per_page=100, page = n)
}, default = NULL)
else 
   return(commits)
}

list <- c(500, 501, 502)

pull_lists <- lapply(list, pull)
库(rgithub)

拉您可以使用futile.logger

然后,您可以使用以下方法设置日志阈值级别:

flog.threshold(INFO)
诸如flog.debug或flog.info之类的函数用于生成日志信息

有关更多详细信息,请参阅:


您需要日志记录还是像
browser()这样的东西可以工作?