X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=branch%2Fdouble_build%2FR%2Flog.R;fp=branch%2Fdouble_build%2FR%2Flog.R;h=0000000000000000000000000000000000000000;hb=42bff07893104a11db95c8d65fe518a336463351;hp=3d74bae7221123116434b59d94747fdb38bdd532;hpb=f0817a2fbc3df0f5daad0a9e1a11d9f295218c0a;p=cran2deb.git diff --git a/branch/double_build/R/log.R b/branch/double_build/R/log.R deleted file mode 100644 index 3d74bae..0000000 --- a/branch/double_build/R/log.R +++ /dev/null @@ -1,66 +0,0 @@ -log_messages <- list() - -log_clear <- function() { - assign('log_messages',list(),envir=.GlobalEnv) -} - -log_add <- function(text,print=T) { - if (print) { - message(text) - } - assign('log_messages',c(log_messages, text),envir=.GlobalEnv) -} - -log_retrieve <- function() { - return(log_messages) -} - -notice <- function(...) { - log_add(paste('N:',...)) -} - -warn <- function(...) { - log_add(paste('W:',...)) -} - -error <- function(...) { - log_add(paste('E:',...)) -} - -fail <- function(...) { - txt <- paste('E:',...) - log_add(txt) - stop(txt) -} - -log_system <- function(...) { - r <- try((function() { - # pipe() does not appear useful here, since - # we want the return value! - # XXX: doesn't work with ; or | ! - tmp <- tempfile('log_system') - on.exit(unlink(tmp)) - cmd <- paste(...) - # unfortunately this destroys ret - #cmd <- paste(cmd,'2>&1','| tee',tmp) - cmd <- paste(cmd,'>',tmp,'2>&1') - ret <- system(cmd) - f <- file(tmp) - output <- readLines(f) - close(f) - unlink(tmp) - return(list(ret,output)) - })()) - if (inherits(r,'try-error')) { - fail('system failed on:',paste(...)) - } - log_add(paste('C:',...)) - for (line in r[[2]]) { - if (!length(grep('^[WENI]:',line))) { - line = paste('I:',line) - } - log_add(line) #,print=F) - } - return(r[[1]]) -} -