-
Notifications
You must be signed in to change notification settings - Fork 0
/
logging.R
37 lines (27 loc) · 1.03 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
# logging.R
# source file to set up convenient logging
# add logger
if(!require(logging)){install.packages("logging")}
library(logging)
# set up loggers and handlers
basicConfig(level='FINEST')
setLevel(30, getHandler('basic.stdout')) # warnings to screen
log_file <- function (writeToFile, fn_log_file) {
# function to set up a new logging file
# var is full path name of log file
addHandler(writeToFile, file=fn_log_file, level='DEBUG') # debug to log file
if ( file.exists(fn_log_file) ) { # start w/ fresh log file
file.remove(fn_log_file)
}
}
summ_warn <- function (name_of_numeric_vector, numeric_vector) {
# function to log some summary data
# first var is name of numeric vector, second var is numeric vector
logwarn('summary stats of %s',name_of_numeric_vector)
stats_sum <- summary(numeric_vector)
stats_names <- paste(names(stats_sum))
logwarn(': %s',stats_names)
stats_values <- paste(stats_sum)
logwarn(': %s',stats_values)
rm(stats_sum,stats_names,stats_values)
}