# @clickout/logger

> A simple logger with four channels: info, error, http and rabbit.

Latest version **0.5.0** (published 2020-12-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install @clickout/logger
pnpm add @clickout/logger
yarn add @clickout/logger
bun add @clickout/logger
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2020-12-15 |
| First published | 2020-11-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 14.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Clickout |
| Maintainers | clickout |

## Links

- npm: https://www.npmjs.com/package/@clickout/logger
- npm.io page: https://npm.io/package/@clickout/logger

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.20
- [winston](https://npm.io/package/winston.md) ^3.3.3
- [json-stringify-safe](https://npm.io/package/json-stringify-safe.md) ^5.0.1
- [winston-elasticsearch](https://npm.io/package/winston-elasticsearch.md) ^0.12.2

## Recent versions

- 0.5.0 (latest) — 2020-12-15
- 0.4.0 — 2020-12-09
- 0.3.1 — 2020-11-30
- 0.3.0 — 2020-11-30
- 0.2.0 — 2020-11-19
- 0.1.3 — 2020-11-18
- 0.1.2 — 2020-11-18
- 0.1.1 — 2020-11-18
- 0.1.0 — 2020-11-17

## README

# @clickout/logger

A simple logger with four channels: `info`, `error`, `http` and `rabbit`.

It uses a hybrid logging system that allows to show only minimal info on console and save more detailed data on elasticsearch.

## Installation

```bash
npm install @clickout/logger
```

## Usage

```js
const Logger = require('@clickout/logger');

const logger = new Logger({
  namespace: 'projectname',
  application: 'appname',
  transports: {
    console: {
      enabled: true,
      format: 'minimal',  // 'minimal' to print only the message, 'full' to print the entire log
      exclude: ['http']
    },
    elasticsearch: {
      enabled: true,
      clientOpts: {
        node: 'http://localhost:9200'
      }
    }
  },
  blacklist: ['accessToken']
});

logger.info('Preparing data...', { customer: { id: 52, email: 'nice@mail.com' }}, { elasticsearch: false });
logger.error('An error occurred', { error: new Error('Invalid parameter') });
logger.http('Http request received', { method: 'GET', url: '/' }, { console: false });
logger.rabbit('Received a new message', { message: { routingKey: 'customer.created', content: { id: 52 }}});
```

Logs are stored on elasticsearch using indexes in the following format `logs-<namespace>-<level>-YYYY.MM`.

You can pass a third options parameter to disable `console` or `elasticsearch` logging for a specific log.

Use the `blacklist` option to obscure certain properties with `********`.

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