`this._addDefaultMeta` is not a function
See original GitHub issuePlease 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:
- Created 5 years ago
- Reactions:6
- Comments:22 (11 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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 from3.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 out3.2.1
tomorrow 💯✨🎉