var util = require('util'),
    raven = require('raven'),
    winston = require('winston')
    _ = require('underscore');

var Sentry = winston.transports.CustomerLogger = function (options) {

  this.name = 'Sentry';
  this._dsn = options.dsn || '';
  this.patchGlobal = options.patchGlobal || false;
  this._sentry = new raven.Client(this._dsn, {logger: options.logger || 'root'});

  if(this.patchGlobal) {
    this._sentry.patchGlobal();
  }

  this._levels_map = {
    silly: 'debug',
    verbose: 'debug',
    info: 'info',
    debug: 'debug',
    warn: 'warning',
    error: 'error'
  }

  // Set the level from your options
  this.level = options.level || 'info';

  // Handle errors
  this._sentry.on('error', function(err) {
    console.error("Sentry error: " + err);
  });

  // Expose sentry client to winston.Logger
  winston.Logger.prototype.sentry_client = this._sentry;
};

//
// Inherit from `winston.Transport` so you can take advantage
// of the base functionality and `.handleExceptions()`.
//
util.inherits(Sentry, winston.Transport);

Sentry.prototype.log = function (level, msg, meta, callback) {
  // TODO: handle this better
  level = this._levels_map[level] || this.level;
  meta = meta || {};

  var extra = _.extend(meta, {
    'level': level
  });

  try {
    if(level == 'error') {
      // Support exceptions logging
      this._sentry.captureError(msg, extra, function() {
        callback(null, true);
      });
    } else {
      this._sentry.captureMessage(msg, extra, function() {
        callback(null, true);
      });
    }
  } catch(err) {
    console.error(err);
  }
};

module.exports = Sentry;

@@ -21,18 +21,16 @@
 util'),%0A
-  
   raven 
@@ -49,18 +49,16 @@
 aven'),%0A
-  
   winsto
@@ -80,20 +80,16 @@
 nston')%0A
-    
 _ = requ
@@ -1101,16 +1101,23 @@
 callback
+, error
 ) %7B%0A  //
@@ -1191,16 +1191,17 @@
 .level;%0A
+%0A
   meta =
@@ -1205,51 +1205,41 @@
 a = 
-meta %7C%7C %7B%7D;%0A%0A  var extra = _.extend(meta, %7B
+%7B%0A    'extra': meta %7C%7C undefined,
 %0A   
@@ -1253,26 +1253,24 @@
 ': level%0A  %7D
-);
 %0A%0A  try %7B%0A  
@@ -1330,16 +1330,154 @@
 logging%0A
+      if (error) %7B%0A        if (msg) %7B%0A          error.message = msg + ', cause: ' + error.message%0A        %7D%0A        msg = error;%0A      %7D%0A%0A
       th
@@ -1501,28 +1501,27 @@
 eError(msg, 
-extr
+met
 a, function(
@@ -1616,20 +1616,19 @@
 ge(msg, 
-extr
+met
 a, funct

Support logging of Error objects