cc2eab1b25192a30f293204749cbaf0f7c6258df
[fnpeditor.git] / src / fnpjs / logging / handlers.js
1 define(function() {
2     
3 'use strict';
4
5
6 return {
7     raven: function(record) {
8         /* global window */
9         if(!window.Raven) {
10             return;
11         }
12
13         var ravenData = {
14             level: record.level,
15             logger: record.loggerName,
16             tags: {}
17         };
18
19         Object.keys(record.data || {})
20             .filter(function(key) {return key !== 'exception';})
21             .forEach(function(key) {
22                 ravenData.tags[key] = record.data[key];
23             });
24
25         if(record.data.exception) {
26             window.Raven.captureException(record.data.exception, ravenData);
27         } else {
28             window.Raven.captureMessage(record.message, ravenData);
29         }
30     }
31 };
32
33 });