[Logging-commits] r87 - in pkg: R inst/unitTest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 3 15:34:36 CEST 2011
Author: mariotomo
Date: 2011-08-03 15:34:36 +0200 (Wed, 03 Aug 2011)
New Revision: 87
Added:
pkg/inst/unitTest/runit.handlers.R
Modified:
pkg/R/logger.R
pkg/R/oo.R
Log:
cleanup and adding tests
Modified: pkg/R/logger.R
===================================================================
--- pkg/R/logger.R 2011-08-03 13:16:48 UTC (rev 86)
+++ pkg/R/logger.R 2011-08-03 13:34:36 UTC (rev 87)
@@ -92,11 +92,9 @@
fullname <- paste('logging.ROOT', name, sep='.')
if(!exists(fullname, envir=logging.options)) {
- logger <- Logger$new(name=name)
- assign(fullname, logger, envir=logging.options)
- logger[['handlers']] <- list()
- logger[['level']] <- namedLevel('INFO')
+ logger <- Logger$new(name=name, handlers=list(), level=namedLevel('INFO'))
updateOptions.environment(logger, ...)
+ logging.options[[fullname]] <- logger
}
logging.options[[fullname]]
}
Modified: pkg/R/oo.R
===================================================================
--- pkg/R/oo.R 2011-08-03 13:16:48 UTC (rev 86)
+++ pkg/R/oo.R 2011-08-03 13:34:36 UTC (rev 87)
@@ -26,7 +26,9 @@
Logger <- setRefClass("Logger",
fields=list(
- name = "character"),
+ name = "character",
+ handlers="list",
+ level="numeric"),
methods=list(
getParent = function() {
@@ -86,7 +88,7 @@
else if(is.numeric(newLevel))
newLevel <- namedLevel(level)
else newLevel <- NA
- level <- newLevel
+ level <<- newLevel
},
getLevel = function() level,
Added: pkg/inst/unitTest/runit.handlers.R
===================================================================
--- pkg/inst/unitTest/runit.handlers.R (rev 0)
+++ pkg/inst/unitTest/runit.handlers.R 2011-08-03 13:34:36 UTC (rev 87)
@@ -0,0 +1,14 @@
+require(svUnit)
+
+# test functions are called in lexicographic order.
+# $Id: runit.data.interaction.R 86 2011-08-03 13:16:48Z mariotomo $
+
+test.looksForHandlersInRootLogger <- function() {
+ basicConfig()
+ checkIdentical(getLogger()[['handlers']][[1]], getHandler('basic.stdout'))
+}
+
+test.lookingForHandlersInObject <- function() {
+ basicConfig()
+ checkIdentical(getLogger()[['handlers']][[1]], getLogger()$getHandler('basic.stdout'))
+}
More information about the Logging-commits
mailing list