Skip to content

Commit

Permalink
Merge pull request #514 from nevir/console-levels
Browse files Browse the repository at this point in the history
Configuration for the console plugin to choose levels. Fixes #391.
  • Loading branch information
benvinegar committed Feb 29, 2016
2 parents 3abd8ba + ebf95b5 commit 40762d9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
*
* Monkey patches console.* calls into Sentry messages with
* their appropriate log levels. (Experimental)
*
* Options:
*
* `levels`: An array of levels (methods on `console`) to report to Sentry.
* Defaults to debug, info, warn, and error.
*/
'use strict';

function consolePlugin(Raven, console) {
function consolePlugin(Raven, console, pluginOptions) {
console = console || window.console || {};
pluginOptions = pluginOptions || {};

var originalConsole = console,
logLevels = ['debug', 'info', 'warn', 'error'],
logLevels = pluginOptions.levels || ['debug', 'info', 'warn', 'error'],
level = logLevels.pop();

var logForGivenLevel = function(l) {
Expand All @@ -36,7 +42,6 @@ function consolePlugin(Raven, console) {
};
};


while(level) {
console[level] = logForGivenLevel(level);
level = logLevels.pop();
Expand Down

0 comments on commit 40762d9

Please sign in to comment.