[Logging-commits] r52 - in pkg: . R inst/unitTest

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 29 16:16:11 CEST 2010


Author: mariotomo
Date: 2010-10-29 16:16:11 +0200 (Fri, 29 Oct 2010)
New Revision: 52

Modified:
   pkg/DESCRIPTION
   pkg/R/logger.R
   pkg/inst/unitTest/runit.data.interaction.R
Log:
logging things that have zero length - take 2!


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2010-10-29 09:15:51 UTC (rev 51)
+++ pkg/DESCRIPTION	2010-10-29 14:16:11 UTC (rev 52)
@@ -1,5 +1,5 @@
 Package: logging
-Version: 0.4-51
+Version: 0.4-52
 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-29 09:15:51 UTC (rev 51)
+++ pkg/R/logger.R	2010-10-29 14:16:11 UTC (rev 52)
@@ -85,7 +85,7 @@
   record <- list()
 
   if (length(list(...)) > 0)
-    msg <- sprintf(msg, lapply(list(...), function(x) paste(x, collapse=',')))
+    msg <- do.call("sprintf", c(msg, lapply(list(...), function(x) if(length(x)==1) x else 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-29 09:15:51 UTC (rev 51)
+++ pkg/inst/unitTest/runit.data.interaction.R	2010-10-29 14:16:11 UTC (rev 52)
@@ -155,3 +155,22 @@
   loginfo("test '%s'", c(0, 1, 2))
   checkEquals("INFO::test '0,1,2'", logged)
 }
+
+test.formattingRecord.moreArguments <- function() {
+  logReset()
+  addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+  logged <<- NULL
+  loginfo("%s: %d", 'name', 123)
+  checkEquals("INFO::name: 123", logged)
+  logged <<- NULL
+  loginfo("%s: %0.2f", 'name', 123.0)
+  checkEquals("INFO::name: 123.00", logged)
+}
+
+test.formattingRecord.moreArguments.lengthMore <- function() {
+  logReset()
+  addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+  logged <<- NULL
+  loginfo("%s '%s'", 'name', c(0, 1, 2))
+  checkEquals("INFO::name '0,1,2'", logged)
+}



More information about the Logging-commits mailing list