Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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