With async/await it would be useful it winston exposed a promise API (this could be done in a backwards compatible way).
const doSomething = async () => {
// this doesn't block
logger.error('some error', new Error('foo'))
// this blocks
await logger.error('some error', new Error('foo'))
// get sentry ID
const sentryErrorId = await logger.error('some error', new Error('foo'))
}
doSomething()
Just to provide a use case. I'm using async/await AWS Lambda function and I need to await the last log statement in the function otherwise I sometimes lose the logged message. Having the log statement awaitable makes the code a bit cleaner. Otherwise, I have to wrap the whole thing in a Promise and resolve that promise in the logging callback or reject it on error and I have lost the advantages of async/await.
@rcollette that specific use case (AWS lambda) is discussed in https://github.com/winstonjs/winston/issues/1250. It's largely unrelated to async/await and Promise and more related to _final and finish events in the Node.js streams API.
Thanks for the feedback. Issue can be closed. Will monitor the other issue.
It's still a valid feature request 鈥撀爄f more folks 馃憤 we'll consider it. Just wanted to be clear that the lack of it is not causing any problems nor the source of any defects.
Still a valid feature request. I've run into a scenario where I really need this, actually, in order to avoid making my code a total mess with callbacks.
@indexzero Please re-consider this.
+1
Most helpful comment
It's still a valid feature request 鈥撀爄f more folks 馃憤 we'll consider it. Just wanted to be clear that the lack of it is not causing any problems nor the source of any defects.