[Logging-commits] r51 - in pkg: . R inst/unitTest
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 29 11:15:51 CEST 2010
Author: mariotomo
Date: 2010-10-29 11:15:51 +0200 (Fri, 29 Oct 2010)
New Revision: 51
Modified:
pkg/DESCRIPTION
pkg/R/logger.R
pkg/inst/unitTest/runit.data.interaction.R
Log:
logging things that have zero length
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2010-10-22 13:30:24 UTC (rev 50)
+++ pkg/DESCRIPTION 2010-10-29 09:15:51 UTC (rev 51)
@@ -1,5 +1,5 @@
Package: logging
-Version: 0.4-49
+Version: 0.4-51
Date: 2010-06-17
Title: a tentative logging package
Author: Mario Frasca <mariotomo at gmail.com>
Modified: pkg/R/logger.R
===================================================================
--- pkg/R/logger.R 2010-10-22 13:30:24 UTC (rev 50)
+++ pkg/R/logger.R 2010-10-29 09:15:51 UTC (rev 51)
@@ -85,7 +85,7 @@
record <- list()
if (length(list(...)) > 0)
- msg <- sprintf(msg, ...)
+ msg <- sprintf(msg, lapply(list(...), function(x) paste(x, collapse=',')))
record$msg <- msg
record$timestamp <- sprintf("%s", Sys.time())
Modified: pkg/inst/unitTest/runit.data.interaction.R
===================================================================
--- pkg/inst/unitTest/runit.data.interaction.R 2010-10-22 13:30:24 UTC (rev 50)
+++ pkg/inst/unitTest/runit.data.interaction.R 2010-10-29 09:15:51 UTC (rev 51)
@@ -65,6 +65,10 @@
logged <<- c(logged, msg)
}
+mockFormatter <- function(record) {
+ paste(record$levelname, record$logger, record$msg, sep = ":")
+}
+
test.recordIsEmitted.rootToRoot <- function() {
logReset()
addHandler(mockAction)
@@ -72,7 +76,7 @@
logdebug('test')
loginfo('test')
logerror('test')
- checkEquals(length(logged), 2)
+ checkEquals(2, length(logged))
}
test.recordIsEmitted.tooDeep <- function() {
@@ -82,7 +86,7 @@
logdebug('test')
loginfo('test')
logerror('test')
- checkEquals(length(logged), 0)
+ checkEquals(0, length(logged))
}
test.recordIsEmitted.unrelated <- function() {
@@ -92,7 +96,7 @@
logdebug('test', logger='other.branch')
loginfo('test', logger='other.branch')
logerror('test', logger='other.branch')
- checkEquals(length(logged), 0)
+ checkEquals(0, length(logged))
}
test.recordIsEmitted.deepToRoot <- function() {
@@ -102,7 +106,7 @@
logdebug('test', logger='other.branch')
loginfo('test', logger='other.branch')
logerror('test', logger='other.branch')
- checkEquals(length(logged), 2)
+ checkEquals(2, length(logged))
}
test.recordIsEmitted.deepToRoot.DI.dropped <- function() {
@@ -113,7 +117,7 @@
logdebug('test', logger='other.branch')
loginfo('test', logger='other.branch')
logerror('test', logger='other.branch')
- checkEquals(length(logged), 2)
+ checkEquals(2, length(logged))
}
test.recordIsEmitted.deepToRoot.DD.passed <- function() {
@@ -125,5 +129,29 @@
logdebug('test', logger='other.branch')
loginfo('test', logger='other.branch')
logerror('test', logger='other.branch')
- checkEquals(length(logged), 3)
+ checkEquals(3, length(logged))
}
+
+test.formattingRecord.lengthZero <- function() {
+ logReset()
+ addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+ logged <<- NULL
+ loginfo("test '%s'", numeric(0))
+ checkEquals("INFO::test ''", logged)
+}
+
+test.formattingRecord.lengthOne <- function() {
+ logReset()
+ addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+ logged <<- NULL
+ loginfo("test '%s'", 12)
+ checkEquals("INFO::test '12'", logged)
+}
+
+test.formattingRecord.lengthMore <- function() {
+ logReset()
+ addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+ logged <<- NULL
+ loginfo("test '%s'", c(0, 1, 2))
+ checkEquals("INFO::test '0,1,2'", logged)
+}
More information about the Logging-commits
mailing list