[Logging-commits] r68 - in oo/pkg: . R inst/unitTest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Apr 15 16:38:26 CEST 2011
Author: mariotomo
Date: 2011-04-15 16:38:25 +0200 (Fri, 15 Apr 2011)
New Revision: 68
Modified:
oo/pkg/DESCRIPTION
oo/pkg/R/methods.R
oo/pkg/inst/unitTest/runit.data.interaction.R
Log:
correcting code and tests.
Modified: oo/pkg/DESCRIPTION
===================================================================
--- oo/pkg/DESCRIPTION 2011-04-15 14:07:54 UTC (rev 67)
+++ oo/pkg/DESCRIPTION 2011-04-15 14:38:25 UTC (rev 68)
@@ -1,5 +1,5 @@
Package: logging.oo
-Version: 0.5-66
+Version: 0.5-68
Date: 2010-06-17
Title: oo interface for the logging package
Author: Mario Frasca <mariotomo at gmail.com>
Modified: oo/pkg/R/methods.R
===================================================================
--- oo/pkg/R/methods.R 2011-04-15 14:07:54 UTC (rev 67)
+++ oo/pkg/R/methods.R 2011-04-15 14:38:25 UTC (rev 68)
@@ -33,6 +33,7 @@
log = function(...) { levellog(..., logger=name) },
setLevel = function(newLevel) { logging::setLevel(newLevel, container=name) },
+ getLevel = function() { logging::getLogger(name)[['level']] },
addHandler = function(...) { logging::addHandler(..., logger=name) },
finest = function(...) { log(loglevels['FINEST'], ...) },
@@ -44,4 +45,4 @@
error = function(...) { log(loglevels["ERROR"], ...) }))
getLogger <- function(name = "")
- Logger$new(name)
+ Logger$new(name=name)
Modified: oo/pkg/inst/unitTest/runit.data.interaction.R
===================================================================
--- oo/pkg/inst/unitTest/runit.data.interaction.R 2011-04-15 14:07:54 UTC (rev 67)
+++ oo/pkg/inst/unitTest/runit.data.interaction.R 2011-04-15 14:38:25 UTC (rev 68)
@@ -1,40 +1,55 @@
require(svUnit)
+require(logging.oo)
# test functions are called in lexicographic order.
# $Id$
test.000.getLoggerWithoutInitializingDoesNotCrash <- function() {
- rootLogger <- Logger$new("")
+ rootLogger <- Logger$new(name="")
}
test.001.defaultLoggingLevelIsINFO <- function() {
basicConfig()
- root <- Logger$new('')
+ root <- Logger$new(name='')
expect <- logging:::loglevels['INFO']
- checkEquals(root[['level']], expect)
+ checkEquals(expect, root$getLevel())
}
test.002.canInitializeTwice <- function() {
basicConfig()
- root <- Logger$new('')
+ root <- Logger$new(name='')
expect <- logging:::loglevels['INFO']
- checkEquals(root[['level']], expect)
+ checkEquals(expect, root$getLevel())
}
+test.003.canUseGetLoggerOnRoot <- function() {
+ basicConfig()
+ root1 <- Logger$new(name='')
+ root2 <- getLogger()
+ checkEquals(root1, root2)
+}
+
+test.004.canUseGetLogger <- function() {
+ basicConfig()
+ root1 <- Logger$new(name='abc')
+ root2 <- getLogger("abc")
+ checkEquals(root1, root2)
+}
+
# end of functions that must be tested first
test.canGetRootLoggerWithoutName <- function() {
- root1 <- Logger$new('')
- root2 <- Logger$new()
+ root1 <- getLogger('')
+ root2 <- getLogger()
checkEquals(root1, root2)
}
test.canSetLoggerLevelByNamedValue <- function() {
basicConfig()
- root <- Logger$new('')
+ root <- getLogger('')
root$setLevel(logging:::loglevels['DEBUG'])
expect <- logging:::loglevels['DEBUG']
- checkEquals(root[['level']], expect)
+ checkEquals(root$getLevel(), expect)
}
test.canSetLoggerLevelByName <- function() {
@@ -42,7 +57,7 @@
root <- getLogger('')
root$setLevel('DEBUG')
expect <- logging:::loglevels['DEBUG']
- checkEquals(root[['level']], expect)
+ checkEquals(root$getLevel(), expect)
}
logged <- NULL
More information about the Logging-commits
mailing list