Skip to content

Message is not sent if shutdown immediately #6

Description

@honeroku

Overview

Since this module doesn't have shutdown function, request to slack is not reached if log4js.shutdown() is called and process is terminated right after message event.

For example:
https://github.com/expressjs/generator/blob/master/templates/js/www.ejs#L68
When I replace this logging with log4js + slack appender, it will not notify to slack.
Even if I put process.exit(1) within shutdown callback like

const log4js = require('log4js');
const logger = log4js.getLogger();

logger.error(bind + ' requires elevated privileges');
log4js.shutdown(() => {
  process.exit(1);
});

it still won't wait process.exit() since slack appender doesn't support it.

As seen in log4js-node, it checks function existence.
https://github.com/log4js-node/log4js-node/blob/master/lib/log4js.js#L117

Appendix

If following proposal diff looks good, I'll make Pull Req.
master...honeroku:feature-support-shutdown

It doesn't guarantee that all request is done, but I suppose 1sec is enough (or even too much) for slack api.
And I don't want over-decorate this tiny module, so I made minimum support.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions