[Logging-commits] r102 - handlers/pkg handlers/pkg/R pkg pkg/R pkg/inst/unitTest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 19 13:28:35 CEST 2012
Author: mariotomo
Date: 2012-04-19 13:28:35 +0200 (Thu, 19 Apr 2012)
New Revision: 102
Modified:
handlers/pkg/DESCRIPTION
handlers/pkg/R/sentry.R
pkg/DESCRIPTION
pkg/R/oo.R
pkg/R/utils.R
pkg/inst/unitTest/runit.data.interaction.R
Log:
adjustments related to initialization of handlers at addition to loggers.
this is not too well documented I fear (handler actions should expect an extra 'dry' parameter and if it is present they should return a logical value expressing whether or not the handler is completely specified.).
Modified: handlers/pkg/DESCRIPTION
===================================================================
--- handlers/pkg/DESCRIPTION 2012-04-19 07:50:41 UTC (rev 101)
+++ handlers/pkg/DESCRIPTION 2012-04-19 11:28:35 UTC (rev 102)
@@ -1,5 +1,5 @@
Package: logging.handlers
-Version: 0.5-101
+Version: 0.7-102
Date: 2011-04-27
Title: extra logging handlers
Author: Mario Frasca <mariotomo at gmail.com>
Modified: handlers/pkg/R/sentry.R
===================================================================
--- handlers/pkg/R/sentry.R 2012-04-19 07:50:41 UTC (rev 101)
+++ handlers/pkg/R/sentry.R 2012-04-19 11:28:35 UTC (rev 102)
@@ -40,7 +40,7 @@
## biocLite("Ruuid")
if(exists('dsn', envir=conf)) {
- ## first time doing something with this handler: parse the dsn
+ ## first time doing something with this handler: parse the dsn
glued <- gsub('(.*)://(.*):(.*)@([^/]+)(.*)/(\\w)', '\\1://\\4\\5::\\2::\\3::\\6',
with(conf, dsn), perl=TRUE)
parts <- strsplit(glued, "::")[[1]]
@@ -51,8 +51,13 @@
rm('dsn', envir=conf)
}
- anythingMissing <- !sapply(c("server", "sentry.private.key", "sentry.public.key", "project"), exists, envir=conf)
+ anythingMissing <- !sapply(c("server", "sentry.private.key", "sentry.public.key", "project"),
+ exists, envir=conf)
+ if(length(list(...)) && 'dry' %in% names(list(...))) {
+ return(all(!anythingMissing))
+ }
+
if(any(anythingMissing)) {
missing <- names(anythingMissing)[anythingMissing]
stop(paste("this handler with sentryAction misses ", paste(missing, collapse=", "), ".\n", sep=""))
@@ -106,5 +111,5 @@
hdr <- c('Content-Type' = 'application/octet-stream', 'X-Sentry-Auth' = x.sentry.auth)
httpPOST(url, httpheader = hdr, postfields = toJSON(params))
-
+
}
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2012-04-19 07:50:41 UTC (rev 101)
+++ pkg/DESCRIPTION 2012-04-19 11:28:35 UTC (rev 102)
@@ -1,5 +1,5 @@
Package: logging
-Version: 0.6-99
+Version: 0.7-102
Date: 2010-06-17
Title: R logging package
Author: Mario Frasca <mariotomo at gmail.com>
Modified: pkg/R/oo.R
===================================================================
--- pkg/R/oo.R 2012-04-19 07:50:41 UTC (rev 101)
+++ pkg/R/oo.R 2012-04-19 11:28:35 UTC (rev 102)
@@ -125,7 +125,9 @@
assign('level', namedLevel(level), handlerEnv)
assign('formatter', formatter, handlerEnv)
removeHandler(handlerName)
- handlers[[handlerName]] <<- handlerEnv
+ if(with(handlerEnv, action)(NA, handlerEnv, dry=TRUE) == TRUE) {
+ handlers[[handlerName]] <<- handlerEnv
+ }
},
finest = function(...) { log(loglevels['FINEST'], ...) },
Modified: pkg/R/utils.R
===================================================================
--- pkg/R/utils.R 2012-04-19 07:50:41 UTC (rev 101)
+++ pkg/R/utils.R 2012-04-19 11:28:35 UTC (rev 102)
@@ -16,13 +16,15 @@
writeToConsole <- function(msg, handler, ...)
{
+ if(length(list(...)) && 'dry' %in% names(list(...)))
+ return(TRUE)
cat(paste(msg, '\n', sep=''))
}
writeToFile <- function(msg, handler, ...)
{
- if (!exists('file', envir=handler))
- stop("handler with writeToFile 'action' must have a 'file' element.\n")
+ if(length(list(...)) && 'dry' %in% names(list(...)))
+ return(exists('file', envir=handler))
cat(paste(msg, '\n', sep=''), file=with(handler, file), append=TRUE)
}
Modified: pkg/inst/unitTest/runit.data.interaction.R
===================================================================
--- pkg/inst/unitTest/runit.data.interaction.R 2012-04-19 07:50:41 UTC (rev 101)
+++ pkg/inst/unitTest/runit.data.interaction.R 2012-04-19 11:28:35 UTC (rev 102)
@@ -69,7 +69,10 @@
}
logged <- NULL
+
mockAction <- function(msg, handler, ...) {
+ if(length(list(...)) && 'dry' %in% names(list(...)))
+ return(TRUE)
logged <<- c(logged, msg)
}
More information about the Logging-commits
mailing list