question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`this._addDefaultMeta` is not a function

See original GitHub issue

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 😃

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
kibertoadcommented, Jan 28, 2019

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

1reaction
indexzerocommented, Jan 29, 2019

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 💯✨🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

self._addDefaultMeta is not a function error still occurs with 3.2.1
So this logger.info.bind(logger) works for me. But I cannot say why. Can anyone tell me why this is not documented anywhere or why....
Read more >
Error after update winston to version 3.2.1. TypeError: self ...
1. TypeError: self._addDefaultMeta is not a function · Ask Question. Asked 3 years, 2 months ago.
Read more >
winstonjs/winston - Gitter
_addDefaultMeta is not a function"error anymore? I have been getting this VERY randomly. I am using the "winston": "3.2.1" and "winston-daily-rotate-file": ...
Read more >
How to use the winston.format.printf function in winston - Snyk
How to use the winston.format.printf function in winston ... Refactor options for logger (not for transport) if (!loggers.has(name)) { // add default Debug ......
Read more >
A Complete Guide to Winston Logging in Node.js - Better Stack
With this change in place, the application will log at the info level if the LOG_LEVEL variable is not set in the environment....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found