rhynl / pino-loggly

send pino logs to loggly
MIT License
2 stars 1 forks source link

`this.emit` is not a function #1

Closed will-e-yams closed 5 years ago

will-e-yams commented 5 years ago

when starting my app, i am getting following error:

TypeError: this.emit is not a function
    at Transform.line [as mapper] (/git/my.api/node_modules/pino-loggly/lib/pino-loggly.js:14:12)
    at Transform.transform [as _transform] (/git/my.api/node_modules/split2/index.js:35:21)
    at Transform._read (/git/my.api/node_modules/split2/node_modules/readable-stream/lib/_stream_transform.js:185:10)
    at Transform._write (/git/my.api/node_modules/split2/node_modules/readable-stream/lib/_stream_transform.js:173:83)
    at doWrite (/git/my.api/node_modules/split2/node_modules/readable-stream/lib/_stream_writable.js:429:139)
    at writeOrBuffer (/git/my.api/node_modules/split2/node_modules/readable-stream/lib/_stream_writable.js:418:5)
    at Transform.Writable.write (/git/my.api/node_modules/split2/node_modules/readable-stream/lib/_stream_writable.js:327:11)
    at Socket.ondata (_stream_readable.js:670:20)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:287:12)
    at readableAddChunk (_stream_readable.js:268:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:122:17)

more details

my command statement (from my package.json) is as follows:

"dev": "nodemon --inspect src/server.js | node src/services/logTransport.js",

here is the transport file:

require("dotenv").config();
const logger = require("pino-loggly");
try {
  logger({
    token: process.env.LOGGLY_CUSTOMER_TOKEN,
    subdomain: process.env.LOGGLY_SUBDOMAIN,
    returnStream: true
  });
} catch (err) {
  console.error("log transport failure", err);
}

this is my first time trying to pipe output to another process, so apologies if i'm missing something obvious.

rhynl commented 5 years ago

Hello @will-e-yams, first, thanks for using this module.

Now, about this issue. I just fixed in version 1.1.1, that does not mean you error is fixed, but now You can see where the real error in your app it is. If you can please try again with the new version.

I have a question. Are you using Pino as the logger of your app? I asked because this module is intended to in conjunction with Pino.

Best regards.