Event emitter -- on logger or transport
See original GitHub issueI’m having an issue catching ‘logged’ notifications and I’m not sure if I’m doing something wrong because the documentation is a little confusing on this point.
It says the winston.Logger is an EventEmitter:
Each instance of winston.Logger is also an instance of an EventEmitter. A logged event will be raised each time a transport successfully logs a message:
but then show an example of listening to events on a winston.transport:
const transport = new winston.transports.Console();
const logger = winston.createLogger({
transports: [transport];
});
transport.on('logged', function (info) {
// `info` log message has now been logged
});
logger.info('CHILL WINSTON!', { seriously: true });
Can (or should) we listen to events on the trasport or the logger?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Writing a custom winston-transport: why to emit logged event?
I would emit the event just in case anyone is listening. I checked winston's roadmap and in version 3.3. 0 the "logged" event...
Read more >Handling and dispatching events with Node.js - LogRocket Blog
This module includes the EventEmitter class, which is used to raise and handle the events. Almost the whole of the Node.js core API...
Read more >The synchronous nature of the EventEmitter. Node.js ...
The event emitter executes all callbacks in a synchronous manner. Every time you call a function, its context is pushed on the top...
Read more >Extending the Event Emitter - YouTube
Get the COMPLETE Course (45% OFF - LIMITED TIME): https://programmingwithmosh.com/courses/nodeSubscribe for more videos: ...
Read more >mole-rpc-transport-eventemitter - npm package - Snyk
We found that mole-rpc-transport-eventemitter demonstrates a positive version release cadence with at least one new version released in the past ...
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’ve just ran a quick test here and I only could have it working if using the following setup:
logged
a bit late…
Wouldn’t bubbling the ‘logged’ event from each transport cause several events with same data?