-
Notifications
You must be signed in to change notification settings - Fork 37
/
logging.R
42 lines (36 loc) · 1.39 KB
/
logging.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# [description] Log message. Thin wrapper around
# futile.logger::flog.info to make main package code a little less verbose
#' @importFrom futile.logger flog.info
log_info <- function(msg, ...){
futile.logger::flog.info(msg = msg, ...)
return(invisible(NULL))
}
# [description] Log warning and throw an R warning. Thin wrapper around
# futile.logger::flog.warn to make main package code a little less verbose
#' @importFrom futile.logger flog.warn
log_warn <- function(msg, ...){
futile.logger::flog.warn(msg = msg, ...)
warning(msg)
return(invisible(NULL))
}
# [description] Log fatal error and throw an R exception. Thin wrapper around
# futile.logger::flog.fatal to make main package code a little less verbose
#' @importFrom futile.logger flog.fatal
log_fatal <- function(msg, ...){
futile.logger::flog.fatal(msg = msg, ...)
stop(msg)
}
#' @importFrom futile.logger flog.threshold logger.options
silence_logger <- function() {
loggerOptions <- futile.logger::logger.options()
if (!identical(loggerOptions, list())){
origLogThreshold <- loggerOptions[[1]][['threshold']]
}
futile.logger::flog.threshold(0)
return(invisible(NULL))
}
#' @importFrom futile.logger INFO flog.threshold
unsilence_logger <- function(thresh = futile.logger::INFO) {
futile.logger::flog.threshold(thresh)
return(invisible(NULL))
}