Setting up a custom transport for Winston

1,616 views
Skip to first unread message

Florian Didron

unread,
Mar 14, 2014, 9:22:22 PM3/14/14
to sai...@googlegroups.com
Hi Everyone, 

I'm trying to setup a custom transport for the Winston logger in sails 0.10.x. 

I'm using the following transport: https://github.com/bazilio91/winston-sentry

My log.js file looks like: 

var winston = require('winston'),
    Sentry = require('winston-sentry');
module.exports = {
  transports: [
        new Sentry({
                level: 'info',
                dsn: "{{DSN}}"
        })
    ]
};

If I send a message to the sails logger in a controller (ex: sails.log.info('Hi Mom!');) the message is displayed on the console not through the transport.

Kind regards,

Florian
 

Stephen Krichten

unread,
Mar 15, 2014, 9:52:58 AM3/15/14
to sai...@googlegroups.com
Based on this...

 * To use Winston w/ captains-log, do the following:

        var captains = CaptainsLog({
            custom: new (require('winston').Logger)({
                levels     : ...,
                transports : ...
            })
        });
 *

I would try something along the lines of ...

var winston = require('winston'),
    Sentry = require('winston-sentry');
module.exports = {
  
  log: {
    custom: new Sentry({
};

Florian Didron

unread,
Mar 15, 2014, 10:15:32 AM3/15/14
to sai...@googlegroups.com
Hi Stephen,

Thanks to the link you sent I was able to make it work. I went for this :

var winston = require('winston'),
    Sentry = require('winston-sentry');
var customLogger = new winston.Logger({
    transports: [

        new Sentry({
                level: 'info',
                dsn: 'dsn'
        })
    ],
});
module.exports = {
  log: {
    custom: customLogger
  }
};

Thanks for the valuable help !

Florian
Reply all
Reply to author
Forward
0 new messages