Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature finish event #103

Open
robertkofoed opened this issue May 16, 2019 · 0 comments
Open

Add feature finish event #103

robertkofoed opened this issue May 16, 2019 · 0 comments

Comments

@robertkofoed
Copy link

robertkofoed commented May 16, 2019

Hey, I discovered that Winston wont emit 'finish'-event. And this package neither!
This is a problem for me in testing with Mocha, and in production with AWS Lambda's.
Now I can discover when its safe to terminate the process.

My Fix:

Example:

const logger = winston.createLogger({
    transports: [
        new (winston.transports.Console)({
            timestamp: true,
            colorize: true,
        })
    ]
})

const transport = new CloudWatchTransport(config)
logger.add(transport)

transport.on('finish', () => { console.log('finished!') })

How you might ask?

By:

relay.js line 63:
if (i === batch.length - 1) this.emit('finish')

index.js line: 16:
this._relay.on('finish', () => this.emit('finish'))

Which in turn allows me to use detect when the Lambda is safe to freeze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant