# pm2-discord-logger

> PM2 Discord Logger

Latest version **1.0.2** (published 2024-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install pm2-discord-logger
pnpm add pm2-discord-logger
yarn add pm2-discord-logger
bun add pm2-discord-logger
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-03-31 |
| First published | 2023-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Derick M. |
| Maintainers | turtlesocks |

## Links

- npm: https://www.npmjs.com/package/pm2-discord-logger
- Repository: https://github.com/TurtIeSocks/pm2-discord-logger
- Homepage: https://github.com/TurtIeSocks/pm2-discord-logger#readme
- Issues: https://github.com/TurtIeSocks/pm2-discord-logger/issues
- npm.io page: https://npm.io/package/pm2-discord-logger

## Dependencies (5)

- [pm2](https://npm.io/package/pm2.md) ^5.3.0
- [pmx](https://npm.io/package/pmx.md) ^1.6.7
- [@pm2/io](https://npm.io/package/@pm2/io.md) ^5.0.0
- [discord.js](https://npm.io/package/discord.js.md) ^14.11.0
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^6.0.0

## Recent versions

- 1.0.2 (latest) — 2024-03-31
- 1.0.1 — 2023-06-18
- 1.0.0 — 2023-06-18

## README

# pm2-discord-logger

PM2 Module for logging events & logs from your PM2 processes to Discord via webhooks. This module is designed to be used with [PM2](https://pm2.keymetrics.io/), it is not a standalone application.

## Install

To install and setup pm2-discord-logger, run the following commands:

```bash
  pm2 install pm2-discord-logger
```

## Config Properties

```ts
interface Config {
  /**
   * Duration in seconds to aggregate messages.
   * @default 1
   * */
  buffer_seconds?: number
  /**
   * Discord webhook url for logs
   * @default null
   * */
  log_url: string | null
  /**
   * Discord webhook url for errors
   * @default null
   * */
  error_url: string | null
  /**
   * Discord webhook url for events
   * @default null
   * */
  event_url: string | null

  // All of these are considered events and logged to the event channel

  /**
   * Enable kill event logs
   * @default false
   * */
  kill: boolean
  /**
   * Enable exception event logs
   * @default true
   * */
  exception: boolean
  /**
   * Enable restart event logs
   * @default true
   * */
  restart: boolean
  /**
   * Enable exit event logs
   * @default false
   * */
  exit: boolean
  /**
   * Enable delete event logs
   * @default false
   * */
  delete: boolean
  /**
   * Enable start event logs
   * @default true
   * */
  start: boolean
  /**
   * Enable stop event logs
   * @default true
   * */
  stop: boolean
  /**
   * Enable online event logs
   * @default true
   * */
  online: boolean
  /**
   * Enable restart overlimit event logs
   * @default true
   * */
  'restart overlimit': boolean
}
```

## Setup

1. Create a Discord Webhook for your server. See [this article](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks) for more information.
2. Set your PM2 config values
3. e.g:

```bash
  pm2 set pm2-discord-logger:log_url https://discordapp.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz
  pm2 set pm2-discord-logger:restart true
```

4. You can set the same or different webhook for each channel but logs will not be recorded if the webhook is not set.

## Development

1. Fork and clone the repo
2. Install dependencies

```bash
  yarn install
```

3. Build the project in watch mode

```bash
  yarn watch
```

4. Copy the `package.json` file into the `dist` folder

```bash
  cp package.json dist
```

5. Run the project locally in PM2

```bash
  cd dist
  pm2 install .
```

## Acknowledgements

Core concept inspired by [ben-sommer/pm2-discord](https://github.com/ben-sommer/pm2-discord-webhook)

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