# bunyan-loggly

> A bunyan stream to transport logs to loggly

Latest version **2.0.1** (published 2022-08-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install bunyan-loggly
pnpm add bunyan-loggly
yarn add bunyan-loggly
bun add bunyan-loggly
```

## 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.1 |
| Published | 2022-08-25 |
| First published | 2014-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Maurice Butler |
| Maintainers | mauricebutler |
| Keywords | bunyan, log, loggly |

## Links

- npm: https://www.npmjs.com/package/bunyan-loggly
- Repository: https://github.com/MauriceButler/bunyan-loggly
- Homepage: https://github.com/MauriceButler/bunyan-loggly#readme
- Issues: https://github.com/MauriceButler/bunyan-loggly/issues
- npm.io page: https://npm.io/package/bunyan-loggly

## Dependencies (2)

- [node-loggly-bulk](https://npm.io/package/node-loggly-bulk.md) ^3.0.1
- [json-stringify-safe](https://npm.io/package/json-stringify-safe.md) ^5.0.1

## 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.1 (latest) — 2022-08-25
- 2.0.0 — 2022-05-29
- 1.4.2 — 2020-04-13
- 1.4.1 — 2019-01-15
- 1.4.0 — 2018-12-03
- 1.3.5 — 2018-05-29
- 1.3.4 — 2018-05-10
- 1.3.3 — 2017-12-06
- 1.3.2 — 2017-10-31
- 1.3.1 — 2017-10-04
- 1.3.0 — 2017-10-03
- 1.2.0 — 2017-01-12
- 1.1.0 — 2016-08-05
- 1.0.0 — 2016-02-08
- 0.0.5 — 2014-03-19
- … 3 more at https://npm.io/package/bunyan-loggly/versions

## README

# bunyan-loggly

A bunyan stream to send logs through to loggly.

## Configuration

bunyan-loggly uses node-loggly under the hood. As such, when configuring bunyan-loggly as a stream for bunyan, you need to pass in the standard and required node-loggly configuration object.

For example:

```javascript
{
    token: "your-really-long-input-token",
    subdomain: "your-subdomain"
}
```

## Usage

This is a basic usage example.

```javascript
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var logglyConfig = {
    token: 'your-account-token',
    subdomain: 'your-sub-domain',
};

var logglyStream = new Bunyan2Loggly(logglyConfig);

// create the logger
var logger = bunyan.createLogger({
    name: 'logglylog',
    streams: [
        {
            type: 'raw',
            stream: logglyStream,
        },
    ],
});

logger.info({});
```

> Please note: you MUST define `type: 'raw'` as bunyan-loggly expects to receive objects so that certain values can be changed as required by loggly (i.e. time to timestamp).

## Buffering

bunyan-loggly supports basic buffering by default and when setup, will only send your logs through to loggly on every x logs. To setup buffering, just pass an integer as the second parameter when creating a new instance of Bunyan2Loggly:

```javascript
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var logglyConfig = {
    token: 'your-account-token',
    subdomain: 'your-sub-domain',
};
var bufferLength = 5;

var logglyStream = new Bunyan2Loggly(logglyConfig, bufferLength);

// create the logger
var logger = bunyan.createLogger({
    name: 'logglylog',
    streams: [
        {
            type: 'raw',
            stream: logglyStream,
        },
    ],
});

logger.info({}); // won't send to loggly
logger.info({}); // won't send to loggly
logger.info({}); // won't send to loggly
logger.info({}); // won't send to loggly
logger.info({}); // will send to loggly
logger.info({}); // won't send to loggly
```

### Buffer Timeout

When buffering, a timeout can be provided to force flushing the buffer after a period of time. To setup a flush timeout, pass a timeout value (in ms) as the third parameter when creating a new instance of Bunyan2Loggly:

```javascript
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var logglyConfig = {
    token: 'your-account-token',
    subdomain: 'your-sub-domain',
};
var bufferLength = 5;
var bufferTimeout = 500;

var logglyStream = new Bunyan2Loggly(logglyConfig, bufferLength, bufferTimeout);

// create the logger
var logger = bunyan.createLogger({
    name: 'logglylog',
    streams: [
        {
            type: 'raw',
            stream: logglyStream,
        },
    ],
});

logger.info({}); // will be sent to loggly in 500ms if buffer threshold is not reached
```

### Turning off buffering

You can turn off buffering by passing `isBulk: false` to the bunnyan2loggly config object.

```javascript
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var logglyConfig = {
    token: 'your-account-token',
    subdomain: 'your-sub-domain',
    isBulk: false,
};

var logglyStream = new Bunyan2Loggly(logglyConfig);

// create the logger
var logger = bunyan.createLogger({
    name: 'logglylog',
    streams: [
        {
            type: 'raw',
            stream: logglyStream,
        },
    ],
});

logger.info({}); // sent to loggly
logger.info({}); // sent to loggly
logger.info({}); // sent to loggly
```

### Loggly request information

Each time log content is sent to loggly, the result of this request will be passed to the optional callback paramer `logglyCallback`

```javascript
var bunyan = require('bunyan');
var Bunyan2Loggly = require('bunyan-loggly');
var logglyConfig = {
    token: 'your-account-token',
    subdomain: 'your-sub-domain',
};

function logglyCallback(error, result, content) {
    // handle loggly callback
}

var logglyStream = new Bunyan2Loggly(logglyConfig, null, null, logglyCallback);
```

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