Winston: Feature request: promise API?

Created on 15 Jun 2017  路  7Comments  路  Source: winstonjs/winston

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()
feature request

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.

All 7 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sinai-doron picture sinai-doron  路  3Comments

ghost picture ghost  路  4Comments

kjin picture kjin  路  3Comments

anks333 picture anks333  路  3Comments

Buzut picture Buzut  路  3Comments