winstonjs / winston-loggly

A Loggly transport for winston
http://github.com/indexzero/winston-loggly
MIT License
85 stars 111 forks source link

Incompatible with mongoose objects #47

Open zoellner opened 8 years ago

zoellner commented 8 years ago

This transporter is incompatible with mongoose objects. A minimal config to reproduce is below. Tested with winston@2.2.0, winston-loggly@1.3.1, mongoose@4.5.9 This is probably the same error as in winstonjs/winston#100

The stack trace end in:

RangeError: Maximum call stack size exceeded

at Object.exports.clone (/Users/test/test-winston/node_modules/winston/lib/winston/common.js:110:52)
[... many more levels of common.js:110:52]
at Object.exports.clone (/Users/test/test-winston/node_modules/winston/lib/winston/common.js:110:52)
at Object.exports.clone (/Users/test/test-winston/node_modules/winston/lib/winston/common.js:110:52)
at Object.exports.clone (/Users/test/test-winston/node_modules/winston/lib/winston/common.js:110:52)
at Loggly.log (/Users/test/test-winston/node_modules/winston-loggly/lib/winston-loggly.js:102:25)
at transportLog (/Users/test/test-winston/node_modules/winston/lib/winston/logger.js:228:15)
at /Users/test/test-winston/node_modules/winston/node_modules/async/lib/async.js:157:13
at _each (/Users/test/test-winston/node_modules/winston/node_modules/async/lib/async.js:57:9)
at Object.async.each (/Users/test/test-winston/node_modules/winston/node_modules/async/lib/async.js:156:9)
at Logger.log (/Users/test/test-winston/node_modules/winston/lib/winston/logger.js:240:9)
at target.(anonymous function) [as info] (/Users/test/test-winston/node_modules/winston/lib/winston/common.js:54:18)
at /Users/test/test-winston/logglyTest.js:42:12
at Query.<anonymous> (/Users/test/test-winston/node_modules/mongoose/lib/query.js:2236:28)
at /Users/test/test-winston/node_modules/kareem/index.js:259:21
at /Users/test/test-winston/node_modules/kareem/index.js:127:16
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

The code to reproduce:

'use strict';

Error.stackTraceLimit = Infinity;

var winston = require('winston');
require('winston-loggly');
var winstonConfig = {
  Loggly: {
    level: 'silly',
    subdomain: process.env.SUBDOMAIN,
    inputToken: process.env.TOKEN,
    tags: ['NodeJS'],
    json: true,
    stripColors: true
  }
};

winston.loggers.add('default', winstonConfig);

var logger = winston.loggers.get('default');

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test-winston-loggly', {db: { safe: true}});

var ModelSchema = new mongoose.Schema({
  field1: String
});

var Model = mongoose.model('Model', ModelSchema);

Model.create({field1: 'test'}, function(err) {
  if (err) {
    console.error(err);
    process.exit(1);
  }
  Model.findOne({}).exec(function(err, doc) {
    if (err) {
      console.error(err);
      process.exit(1);
    }
    console.log('expecting log of document: ', JSON.stringify(doc, null, 2));
    logger.info('test log', {doc: doc});
  });
});
mansona commented 8 years ago

We've just hit this error, any chance of getting the Decycle implementation merged and released?