log4js-node / log4js-node/slack

Message is not sent if shutdown immediately

Open
#6 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8
Forks
8
PR merge metrics
No merged PRs in 30d

Description

# 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.
https://github.com/log4js-node/slack/compare/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Slack appender and the linked feature-support-shutdown comparison, then review how log4js.shutdown() checks for shutdown support. Verify the immediate-termination example and the proposed callback behavior; done means the Slack request can finish or be given the proposed wait before process exit.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.