[Logging-commits] r80 - in handlers/pkg: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Apr 28 11:00:43 CEST 2011
Author: mariotomo
Date: 2011-04-28 11:00:43 +0200 (Thu, 28 Apr 2011)
New Revision: 80
Modified:
handlers/pkg/DESCRIPTION
handlers/pkg/R/sentry.R
Log:
work in progress
Modified: handlers/pkg/DESCRIPTION
===================================================================
--- handlers/pkg/DESCRIPTION 2011-04-27 13:31:46 UTC (rev 79)
+++ handlers/pkg/DESCRIPTION 2011-04-28 09:00:43 UTC (rev 80)
@@ -1,5 +1,5 @@
Package: logging.handlers
-Version: 0.5-68
+Version: 0.5-80
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 2011-04-27 13:31:46 UTC (rev 79)
+++ handlers/pkg/R/sentry.R 2011-04-28 09:00:43 UTC (rev 80)
@@ -27,13 +27,6 @@
##
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")
- sentry.server <- with(conf, server)
- sentry.key <- with(conf, sentry.key)
-
if(!all(c(require(RCurl),
require(Ruuid),
require(rjson))))
@@ -43,20 +36,37 @@
## source("http://bioconductor.org/biocLite.R")
## biocLite("Ruuid")
- if(missing(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")
+
+ sentry.server <- with(conf, server)
+ sentry.key <- with(conf, sentry.key)
+ client.name <- tryCatch(with(conf, client.name), error = function(e) "r.logging")
+
+ if(missing(record)) # needed for `level` and `timestamp` fields.
stop("sentryAction needs to receive the logging record.\n")
- functionCallStack = sys.calls()
+ ## `view.name`: the name of the function where the log record was generated.
+ functionCallStack <- sys.calls()
+ view.name <- tryCatch({
+ perpretator.call <- functionCallStack[length(functionCallStack) - 4][[1]]
+ perpretator.name <- as.character(perpretator.call)[[1]]
+ view.name <- perpretator.name
+ }, error = function(e) "fired at command line")
- data <- list(level=as.numeric(record$level),
- message=msg,
- view=deparse(functionCallStack[length(functionCallStack) - 4][[1]]),
- message_id=as.character(getuuid()),
- logger=record$logger,
- data=list(sentry=""))
- if (exists('app_name', envir=conf))
- data$server_name <- with(conf, app_name)
+ data <- list("level" = as.numeric(record$level),
+ "message" = msg,
+ "view" = view.name,
+ "message_id" = as.character(getuuid()),
+ "logger" = record$logger,
+ "server_name" = client.name)
+ metadata <- list()
+ metadata$call_stack <- paste(lapply(functionCallStack, deparse), collapse=" || ")
+ data$data <- metadata
+
repr <- as.character(base64(toJSON(data)))
url <- paste(sentry.server, "store", "", sep="/")
More information about the Logging-commits
mailing list