File: rsdmx_logger.R

package info (click to toggle)
r-cran-rsdmx 1%3A0.6-5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,024 kB
  • sloc: sh: 14; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download
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
#' rsdmxLogger
#'
#' @docType class
#' @export
#' @keywords logger
#' @return Object for modelling a simple logger
#'
#' @section Abstract Methods:
#' \describe{
#'  \item{\code{INFO(text)}}{
#'    Logger to report information. Used internally
#'  }
#'  \item{\code{WARN(text)}}{
#'    Logger to report warnings. Used internally
#'  }
#'  \item{\code{ERROR(text)}}{
#'    Logger to report errors. Used internally
#'  }
#' }
#' 
#' @note Logger class used internally by rsdmx
#' @export
#' 
rsdmxLogger <- R6Class("rsdmxLogger",
   private = list(
     enabled = FALSE,
     logger = function(type, text){
       if(private$enabled) cat(sprintf("[rsdmx][%s] %s \n", type, text))
     }
   ),
   public = list(
     #logger
     INFO = function(text){private$logger("INFO", text)},
     WARN = function(text){private$logger("WARN", text)},
     ERROR = function(text){private$logger("ERROR", text)},
     initialize = function(enabled = TRUE){
       private$enabled <- enabled
     }
   )
)