# console-to-slack

> Module for integrating console usage with Slack webhooks.

Latest version **2.0.0** (published 2024-08-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install console-to-slack
pnpm add console-to-slack
yarn add console-to-slack
bun add console-to-slack
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-08-19 |
| First published | 2017-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=20.0.0 |
| Dependencies | 0 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | TechChange |
| Maintainers | techchange, jantonso, beckybell, apettenati |
| Keywords | slack, webhook, console, log, warn, error, javascript |

## Links

- npm: https://www.npmjs.com/package/console-to-slack
- Repository: https://github.com/TechChange/console-to-slack
- Homepage: https://github.com/techchange/console-to-slack#readme
- Issues: https://github.com/techchange/console-to-slack/issues
- npm.io page: https://npm.io/package/console-to-slack

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-08-19
- 1.1.0 — 2023-02-07
- 1.0.2 — 2023-01-30
- 1.0.1 — 2023-01-27
- 1.0.0 — 2022-08-04
- 0.2.0 — 2022-07-05
- 0.1.2 — 2017-12-12
- 0.1.1 — 2017-02-14
- 0.1.0 — 2017-02-09

## README

console-to-slack
==========================

[NPM module](https://www.npmjs.com/package/console-to-slack) for integrating with Slack webhooks. Currently supports overriding console.log, console.warn, and console.error to send messages to Slack.

## Installation

```
npm install console-to-slack
```

Ensure that Slack incoming webhooks are setup for your team and channel, which you can find more information about here: https://api.slack.com/incoming-webhooks

## Usage

Include this module:
```javascript
var consoleToSlack = require('console-to-slack');
```

You can use the following methods:

- **consoleToSlack.init( defaultUrl, consoleLevel, options )**
	- **defaultUrl (required)**: The url of the default slack thread to send messages to.
	- **consoleLevel (required)**: The console level (1 - 4) which specifies which console usage to override. Default is to not override anything.
		- 1 = console.log
		- 2 = console.warn
		- 3 = console.error
		- 4 = all
	- **options (optional)**: An object to pass in optional parameters, as described below.

```javascript
var slackUrl = 'https://hooks.slack.com/services/AAAAAAAAA/BBBBBBBBB/CCCCCCCCCCCCCCCCCCCCCCCC';

consoleToSlack.init(slackUrl, 3);
```

#### Options

The following fields are available to be passed in via options:

- **options.name**: The name of the service. This is necessary to help distinguish the location of the Slack message.
- **options.channels**: Can customize channels for log, warn, and error via slack channel name and/or url. If name and url is not specified for log, warn, or error, the messages will be sent to the default url.

Example:

```javascript
var options = {
	name: 'My Example Service',
	channels: {
		log: {
			name: '#console_log',
			url: 'https://hooks.slack.com/services/AAAAAAAAA/BBBBBBBBB/CCCCCCCCCCCCCCCCCCCCCCCC'
		},
		warn: {
			name: '#console_warn',
			url: 'https://hooks.slack.com/services/AAAAAAAAA/BBBBBBBBB/CCCCCCCCCCCCCCCCCCCCCCCC'
		},
		error: {
			name: '#console_error',
			url: 'https://hooks.slack.com/services/AAAAAAAAA/BBBBBBBBB/CCCCCCCCCCCCCCCCCCCCCCCC'
		}
	}
}
```

#### Important Notes

1. You will still see the normal console.log, console.warn, and console.error behavior, in addition to the slack messages.

---
_Source: https://npm.io/package/console-to-slack · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
