⚠️ DEPRECATED — moved to yingyeothon/tslibThis repository is archived and no longer maintained. Its packages now live in the
tslibmonorepo and are published from there as v2.0.0+ with a redesigned API (see each package's README there for migration notes).
Package here (last release from this repo) Successor in tslib@yingyeothon/slack-logger@yingyeothon/logger-slack(renamed)Versions published from this repository stay on npm but are marked deprecated.
Simple logger using Slack webhook.
npm i --save @yingyeothon/slack-logger
# yarn add @yingyeothon/slack-loggerimport { getLogger } from "@yingyeothon/slack-logger";
const logger = getLogger("handleMessage", __filename);
const context = {
api: "/api/get",
params: {
path: "abc",
query: "def",
},
};
logger.info({ context }, "Something for info");
logger.trace({ context }, "Something for trace");
try {
throw new Error("What's wrong!");
} catch (error) {
logger.error({ error, context }, "Error occurred");
}
await logger.flushSlack();| Variable | Description |
|---|---|
| SLACK_WEBHOOK_URL | Slack incoming Webhook URL |
| SLACK_CHANNEL | Channel Id of Slack |
| SLACK_USER_NAME | User name for Slack |
| CONSOLE_LOG_LEVEL | Log level for Console logging |
| SLACK_LOG_LEVEL | Log level for Slack logging |
const enum LogLevel {
trace = 1,
debug = 2,
info = 3,
warn = 4,
error = 5,
fatal = 6,
silent = 99,
}MIT