From: Aleksander Ɓukasz Date: Mon, 30 Dec 2013 12:16:05 +0000 (+0100) Subject: logging: Raven handler X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/25175ece1135d9757fb1e5782c20d12ba804a0d4 logging: Raven handler This handler assumes that ravenjs is already installed in a global scope. --- diff --git a/src/fnpjs/logging/handlers.js b/src/fnpjs/logging/handlers.js index c15d17f..966af4e 100644 --- a/src/fnpjs/logging/handlers.js +++ b/src/fnpjs/logging/handlers.js @@ -3,6 +3,26 @@ define(function() { 'use strict'; -return {}; +return { + raven: function(msg, level, data) { + /* global window */ + if(!window.Raven) { + return; + } + + var ravenData = {}; + + if(data.exception) { + window.Raven.captureException(data.exception); + } else { + Object.keys(data || {}).forEach(function(key) { + ravenData[key] = data[key]; + }); + ravenData.tags = ravenData.tags || {}; + ravenData.tags.level = level; + window.Raven.captureMessage(msg, ravenData); + } + } +}; }); \ No newline at end of file