editor: metadata wip - refactoring, removing unused code
[fnpeditor.git] / src / fnpjs / logging / handlers.js
1 define(function() {
2     
3 'use strict';
4
5
6 return {
7     console: function(record) {
8         /* global console */
9         var method;
10         if(console) {
11             method = (typeof console[record.level] === 'function') ? record.level : 'log';
12             console[method](record.message);
13         }
14     },
15     raven: function(record) {
16         /* global window */
17         if(!window.Raven) {
18             return;
19         }
20
21         var ravenData = {
22             level: record.level,
23             logger: record.loggerName,
24             tags: {}
25         };
26
27         Object.keys(record.data || {})
28             .filter(function(key) {return key !== 'exception';})
29             .forEach(function(key) {
30                 ravenData.tags[key] = record.data[key];
31             });
32
33         if(record.data && record.data.exception) {
34             window.Raven.captureException(record.data.exception, ravenData);
35         } else {
36             window.Raven.captureMessage(record.message, ravenData);
37         }
38     }
39 };
40
41 });