# nestjs-graylog

> NestJS provider to integrates with Graylog

Latest version **2.0.3** (published 2024-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-graylog
pnpm add nestjs-graylog
yarn add nestjs-graylog
bun add nestjs-graylog
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2024-02-06 |
| First published | 2022-08-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 132.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Phitsanu Chuamuangphan |
| Maintainers | appotter |
| Keywords | nestjs, graylog, gelf, logger |

## Links

- npm: https://www.npmjs.com/package/nestjs-graylog
- Repository: https://github.com/appotter/nestjs-graylog
- Homepage: https://github.com/appotter/nestjs-graylog#readme
- Issues: https://github.com/appotter/nestjs-graylog/issues
- npm.io page: https://npm.io/package/nestjs-graylog

## Dependencies (2)

- [graylog2](https://npm.io/package/graylog2.md) ^0.2.1
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^8.0.0 || ^9.0.0 || ^10.0.0

## 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.3 (latest) — 2024-02-06
- 2.0.2 — 2024-02-05
- 2.0.1 — 2024-01-31
- 2.0.0 — 2022-08-28
- 1.0.7 — 2022-08-15
- 1.0.6 — 2022-08-15
- 1.0.5 — 2022-08-15
- 1.0.3 — 2022-08-15
- 1.0.2 — 2022-08-15
- 1.0.0 — 2022-08-15

## README

<div align="center">
  <a href="http://nestjs.com/" target="_blank">
    <img src="https://nestjs.com/img/logo_text.svg" width="150" alt="Nest Logo" />
  </a>
</div>

<h3 align="center">NestJS Graylog</h3>

<div align="center">
  <a href="https://nestjs.com" target="_blank">
    <img src="https://img.shields.io/badge/built%20with-NestJs-red.svg" alt="Built with NestJS">
  </a>
</div>

### Introduction

This is a simple wrapper of [Graylog2](https://github.com/Wizcorp/node-graylog2) client library for NestJS.

### Installation

```bash
npm install --save nestjs-graylog graylog2
```

### Usage

#### Importing module

```typescript
import { GraylogModule, GraylogService } from 'nestjs-graylog';

@Module({
  imports: [
    GraylogModule.register({
      serviers: [
        { host: '127.0.0.1', port: 12201 }
      ],
      hostname: 'hostname',// optional, default: os.hostname()
      facility: 'Node.js',// optional, default: Node.js
      bufferSize: 1400,// optional, default: 1400
    }),
  ],
  providers: [GraylogService],
  exports: [GraylogService],
})
export class GraylogProviderModule {}
```

#### Importing module Async

```typescript
import { GraylogModule, GraylogService } from 'nestjs-graylog';
import { ConfigModule, ConfigService } from '@nestjs/config';

@Module({
  imports: [
    GraylogModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        servers: [
          {
            host: configService.get('GRAYLOG_HOST'),
            port: +configService.get('GRAYLOG_PORT'),
          },
        ],
        facility: configService.get('GRAYLOG_FACILITY'),
      }),
    }),
  ],
  providers: [GraylogService],
  exports: [GraylogService],
})
export class GraylogProviderModule {}
```
#### Calling Method

```typescript
import { GraylogService } from 'nestjs-graylog';

@Injectable()
export class YourService {
  constructor(private graylogService: GraylogService) {}

  async foo() {
    await this.graylogService.debug('test message', { foo: 'bar' });
  }

  // Also available in
  // this.graylogService.emergency('message')
  // this.graylogService.alert('message')
  // this.graylogService.critical('message')
  // this.graylogService.error('message')
  // this.graylogService.warning('message')
  // this.graylogService.notice('message')
  // this.graylogService.info('message')
}
```

## Contributing

Contributions welcome!

## Author
**Phitsanu Chuamuangphan ([GitHub](https://github.com/appotter))**

## LICENSE

MIT

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