Mercurial > repos > prog > lcmsmatching
comparison MsDbLogger.R @ 0:e66bb061af06 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
author | prog |
---|---|
date | Tue, 12 Jul 2016 12:02:37 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e66bb061af06 |
---|---|
1 if ( ! exists('MsDbLogger')) { # Do not load again if already loaded | |
2 | |
3 source('MsDbObserver.R') | |
4 | |
5 ##################### | |
6 # CLASS DECLARATION # | |
7 ##################### | |
8 | |
9 MsDbLogger <- setRefClass("MsDbLogger", contains = 'MsDbObserver', fields = list(.verbose = 'numeric', .file = 'ANY' )) | |
10 | |
11 ############### | |
12 # CONSTRUCTOR # | |
13 ############### | |
14 | |
15 MsDbLogger$methods( initialize = function(verbose = 1, file = NULL, ...) { | |
16 | |
17 .verbose <<- if ( ! is.null(verbose) && ! is.na(verbose)) verbose else 1 | |
18 .file <<- if ( ! is.null(file) && ! is.na(file)) file else stderr() | |
19 | |
20 callSuper(...) # calls super-class initializer with remaining parameters | |
21 }) | |
22 | |
23 ############ | |
24 # PROGRESS # | |
25 ############ | |
26 | |
27 MsDbLogger$methods( progress = function(msg, level = 1) { | |
28 if (.self$.verbose >= level) | |
29 cat(msg, "\n", sep = '', file = .self$.file) | |
30 }) | |
31 | |
32 } # end of load safe guard |