[Logging-commits] r77 - in handlers/pkg: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 27 13:16:46 CEST 2011


Author: mariotomo
Date: 2011-04-27 13:16:46 +0200 (Wed, 27 Apr 2011)
New Revision: 77

Modified:
   handlers/pkg/R/sentry.R
   handlers/pkg/man/sentry.Rd
Log:
work in progress


Modified: handlers/pkg/R/sentry.R
===================================================================
--- handlers/pkg/R/sentry.R	2011-04-27 07:26:37 UTC (rev 76)
+++ handlers/pkg/R/sentry.R	2011-04-27 11:16:46 UTC (rev 77)
@@ -19,39 +19,49 @@
 ##
 ## Usage      : library(logging.handlers)
 ##
-## $Id: logger.R 60 2011-02-02 09:47:04Z mariotomo $
+## $Id$
 ##
 ## initial programmer :  Mario Frasca
 ##
 ## initial date       :  20110426
 ##
 
-sentryAction <- function(msg, conf, record) {
+sentryAction <- function(msg, conf, record, ...) {
   if (!exists('server', envir=conf))
     stop("handler with sentryAction must have a 'server' element.\n")
+  if (!exists('sentry.key', envir=conf))
+    stop("handler with sentryAction must have a 'sentry.key' element.\n")
 
   if(!all(c(require(RCurl),
             require(Ruuid),
             require(rjson))))
     stop("sentryAction depends on RCurl, Ruuid, rjson.")
 
+  ## you install Ruuid this way (not with install.packages).
+  ## source("http://bioconductor.org/biocLite.R")
+  ## biocLite("Ruuid")
+
   if(missing(record))
     stop("sentryAction needs to receive the logging record.\n")
 
-  ## source("http://bioconductor.org/biocLite.R")
-  ## biocLite("Ruuid")
-
   functionCallStack = sys.calls()
-  print(functionCallStack)
+  print(dput(functionCallStack))
+  print(functionCallStack[length(functionCallStack) - 1][[1]])
 
   data <- list(timestamp=record$timestamp,
-               level=record$level,
+               level=as.numeric(record$level),
                message=msg,
-               view=deparse(functionCallStack[length(functionCallStack) - 1][[1]]),
+               view=deparse(functionCallStack[length(functionCallStack) - 4][[1]]),
                message_id=as.character(getuuid()),
                logger_name=record$logger,
-               metadata=list())
+               data=list(sentry=""))
   repr <- as.character(base64(toJSON(data)))
+  print(repr)
 
-  
+  ## TODO: this command line must be made R
+  ## curl -d key=lizard12345 -d format=json -d data=repr http://sentry.lizardsystem.nl/store/
+  url <- paste(with(conf, server), "store", "", sep="/")
+
+  reply <- postForm(url, style="POST", format="json", key=with(conf, sentry.key), data=repr)
+  print(reply)
 }


Property changes on: handlers/pkg/R/sentry.R
___________________________________________________________________
Added: svn:keywords
   + Id

Modified: handlers/pkg/man/sentry.Rd
===================================================================
--- handlers/pkg/man/sentry.Rd	2011-04-27 07:26:37 UTC (rev 76)
+++ handlers/pkg/man/sentry.Rd	2011-04-27 11:16:46 UTC (rev 77)
@@ -1,5 +1,5 @@
 % File man/sentry.Rd
-% $Id: getLogger.Rd 11 2010-04-03 18:54:20Z mariotomo $
+% $Id$
 
 \name{sentry}
 \alias{sentryAction}
@@ -17,12 +17,13 @@
   sentry server.
 }
 \usage{
-sentryAction(msg, conf, record)
+sentryAction(msg, conf, record, ...)
 }
 \arguments{
   \item{msg}{the formatted record}
   \item{conf}{the handler environment}
   \item{record}{the full unformatted record}
+  \item{...}{left open for future enhancements}
 }
 \examples{
 library(logging)
@@ -30,8 +31,8 @@
 
 basicConfig()
 
-addHandler("sentry", sentryAction, server="http://sentry.somedomain.com/")
+addHandler("sentry", sentryAction, server="http://sentry.lizardsystem.nl/", sentry.key="ben niet gek")
 
-logdebug("not sent, basic is INFO")
-logwarn("sent and timestamped")
+\dontrun{logdebug("not sent, basic is INFO")}
+\dontrun{logwarn("sent and timestamped")}
 }


Property changes on: handlers/pkg/man/sentry.Rd
___________________________________________________________________
Added: svn:keywords
   + Id



More information about the Logging-commits mailing list