[Logging-commits] r60 - in pkg: . R inst/unitTest man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Feb 2 10:47:04 CET 2011
Author: mariotomo
Date: 2011-02-02 10:47:04 +0100 (Wed, 02 Feb 2011)
New Revision: 60
Modified:
pkg/DESCRIPTION
pkg/R/logger.R
pkg/inst/unitTest/runit.data.interaction.R
pkg/man/log.Rd
Log:
the logging function now removes leading and trailing whitespace from the text of the messages after inserting the parameters with sprintf.
the formatters attached to the handlers now receive the whitespace stripped message.
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2011-02-01 12:33:05 UTC (rev 59)
+++ pkg/DESCRIPTION 2011-02-02 09:47:04 UTC (rev 60)
@@ -1,5 +1,5 @@
Package: logging
-Version: 0.4-52
+Version: 0.4-60
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 2011-02-01 12:33:05 UTC (rev 59)
+++ pkg/R/logger.R 2011-02-02 09:47:04 UTC (rev 60)
@@ -86,6 +86,10 @@
if (length(list(...)) > 0)
msg <- do.call("sprintf", c(msg, lapply(list(...), function(x) if(length(x)==1) x else paste(x, collapse=','))))
+
+ ## strip leading and trailing whitespace from the final message.
+ msg <- sub("[[:space:]]+$", '', msg)
+ msg <- sub("^[[:space:]]+", '', msg)
record$msg <- msg
record$timestamp <- sprintf("%s", Sys.time())
Modified: pkg/inst/unitTest/runit.data.interaction.R
===================================================================
--- pkg/inst/unitTest/runit.data.interaction.R 2011-02-01 12:33:05 UTC (rev 59)
+++ pkg/inst/unitTest/runit.data.interaction.R 2011-02-02 09:47:04 UTC (rev 60)
@@ -174,3 +174,14 @@
loginfo("%s '%s'", 'name', c(0, 1, 2))
checkEquals("INFO::name '0,1,2'", logged)
}
+
+test.formattingRecord.strips.whitespace <- function() {
+ logReset()
+ addHandler(mockAction, level='DEBUG', logger='', formatter=mockFormatter)
+ logged <<- NULL
+ loginfo("a string with trailing whitespace \n")
+ checkEquals("INFO::a string with trailing whitespace", logged)
+ logged <<- NULL
+ loginfo(" this string has also leading whitespace ")
+ checkEquals("INFO::this string has also leading whitespace", logged)
+}
Modified: pkg/man/log.Rd
===================================================================
--- pkg/man/log.Rd 2011-02-01 12:33:05 UTC (rev 59)
+++ pkg/man/log.Rd 2011-02-02 09:47:04 UTC (rev 60)
@@ -17,6 +17,8 @@
a log record gets timestamped and will be independently formatted by
each of the handlers handling it.
+ leading and trailing whitespace is stripped from the final message.
+
}
\usage{
logdebug(msg, ..., logger='')
More information about the Logging-commits
mailing list