winston: `this._addDefaultMeta` is not a function

Please tell us about your environment:

  • winston version?
    • winston@2
    • winston@3
  • node -v outputs: 8.9.3
  • _Operating System? Linux & Mac
  • Language? Es6

What is the problem?

Since the 3.2.0 release we are getting the following:

error: this._addDefaultMeta is not a function {"stack":"TypeError: this._addDefaultMeta is not a function\n    at APIClient.(anonymous function) [as logger] (/Users/erriettakostala/prototype1/server/node_modules/winston/lib/winston/create-logger.js:55:16)\n  

We’re just calling log the same way as before.

  const logger = winston.createLogger({
    level: process.env.LOG_LEVEL || 'debug',
    format: process.env.NODE_ENV === 'production' ? winston.format.json() : winston.format.simple(),
    transports: [ new winston.transports.Console() ]
  })

logger.log({
  level: 'info',
  message: ''
});

What do you expect to happen instead?

The code to not crash 😃

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 22 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I guess we need to use arrow function there, it autobinds. Will try to come up with a PR for that ASAP.

Howdy folks – thanks for reporting this. I had noticed it in passing when writing an unrelated test for 3.2.0, but didn’t realize it was a regression from 3.1.0.

The regression itself was introduced in #1483. Very thankful @soldair added test coverage for the scenario because fixing this would have introduced another regression without it ❤️.

#1579 is an attempt to fix this issue. Currently it appears to be neutral from a performance perspective (yay), but unfortunately not the most obvious, straight-forward, or otherwise “elegant” solution (boo).

Given that https://github.com/winstonjs/winston/pull/1539 was overlooked for 3.2.0, if we can get some 👀👀👀from folks on #1579 and they are 👍then we should be in good shape to push out 3.2.1 tomorrow 💯✨🎉