[Logging-commits] r101 - in handlers/pkg: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 19 09:50:41 CEST 2012


Author: mariotomo
Date: 2012-04-19 09:50:41 +0200 (Thu, 19 Apr 2012)
New Revision: 101

Modified:
   handlers/pkg/DESCRIPTION
   handlers/pkg/R/sentry.R
Log:
work on the sentry handler.

Modified: handlers/pkg/DESCRIPTION
===================================================================
--- handlers/pkg/DESCRIPTION	2012-04-18 06:18:38 UTC (rev 100)
+++ handlers/pkg/DESCRIPTION	2012-04-19 07:50:41 UTC (rev 101)
@@ -1,5 +1,5 @@
 Package: logging.handlers
-Version: 0.5-99
+Version: 0.5-101
 Date: 2011-04-27
 Title: extra logging handlers
 Author: Mario Frasca <mariotomo at gmail.com>

Modified: handlers/pkg/R/sentry.R
===================================================================
--- handlers/pkg/R/sentry.R	2012-04-18 06:18:38 UTC (rev 100)
+++ handlers/pkg/R/sentry.R	2012-04-19 07:50:41 UTC (rev 101)
@@ -39,11 +39,25 @@
   ## source("http://bioconductor.org/biocLite.R")
   ## biocLite("Ruuid")
 
-  for(k in c("server", "sentry.private.key", "sentry.public.key", "project")) {
-    if (!exists(k, envir=conf))
-      stop(paste("handler with sentryAction must have a '", k, "' element.\n", sep=""))
+  if(exists('dsn', envir=conf)) {
+    ## first time doing something with this handler: parse the dsn 
+    glued <- gsub('(.*)://(.*):(.*)@([^/]+)(.*)/(\\w)', '\\1://\\4\\5::\\2::\\3::\\6',
+                  with(conf, dsn), perl=TRUE)
+    parts <- strsplit(glued, "::")[[1]]
+    assign('server', parts[1], envir=conf)
+    assign('sentry.public.key', parts[2], envir=conf)
+    assign('sentry.private.key', parts[3], envir=conf)
+    assign('project', parts[4], envir=conf)
+    rm('dsn', envir=conf)
   }
 
+  anythingMissing <- !sapply(c("server", "sentry.private.key", "sentry.public.key", "project"), exists, envir=conf)
+
+  if(any(anythingMissing)) {
+    missing <- names(anythingMissing)[anythingMissing]
+    stop(paste("this handler with sentryAction misses ", paste(missing, collapse=", "), ".\n", sep=""))
+  }
+
   sentry.server <- with(conf, server)
   sentry.private.key <- with(conf, sentry.private.key)
   sentry.public.key <- with(conf, sentry.public.key)
@@ -64,7 +78,7 @@
   params <- list("project" = project,
                "event_id" = gsub("-", "", as.character(getuuid())),
                "culprit" = view.name,
-               "timestamp" = format(record$timestamp, "%Y-%m-%dT%H:%M:%S"),
+               "timestamp" = record$timestamp,
                "message" = msg,
                "level" = as.numeric(record$level),
                "logger" = record$logger,
@@ -91,6 +105,6 @@
   x.sentry.auth <- paste("Sentry", paste(x.sentry.auth.parts, collapse=", "))
   hdr <- c('Content-Type' = 'application/octet-stream', 'X-Sentry-Auth' = x.sentry.auth)
 
-  httpPOST(url, httpheader = hdr, postfields = toJSON(params), verbose = TRUE)
+  httpPOST(url, httpheader = hdr, postfields = toJSON(params))
   
 }



More information about the Logging-commits mailing list