1.0.6 • Published 3 years ago

good-bunyan-gcloud-formatters v1.0.6

Weekly downloads
165
License
MIT
Repository
github
Last release
3 years ago

good-bunyan-gcloud-formatters

formatters for good-bunyan to enable Stackdriver to process structured logs

Build Status Codecov

Inspiration

Based on the default good-bunyan formatters, but extended to include the proper format for Stackdriver's processing of structured logs.

Usage

npm MIT license

Intended for use with good-bunyan and @google-cloud/logging-bunyan.

Installation

$ npm install good-bunyan good-bunyan-gcloud-formatters @google-cloud/logging-bunyan --save

Configuration using good

import hapi from 'hapi';
import bunyan from 'bunyan';
import {LoggingBunyan} from '@google-cloud/logging-bunyan';
import * as formatters from 'good-bunyan-gcloud-formatters';

const stackDriver = new LoggingBunyan({
  logName: 'flex_request_log'
});

const server = new hapi.server();

await server.register({
    plugin: require('good'),
    options: {
        ops: {interval: 1000},
        reporters: {
            bunyan: [{
                module: 'good-bunyan',
                args: [
                    {log: '*', request: '*', response: '*', error: '*'},
                    {
                        logger: bunyan.createLogger({
                            name: 'logger',
                            streams: ['production' === process.env.NODE_ENV ? stackDriver.stream('trace') : {stream: process.stdout}]
                        }),
                        levels: {
                          response: 'info',
                          request: 'info'
                        },
                        formatters
                    }
                ]
            }]
        }
    }
});

await server.start();

Contributing

Conventional Commits Commitizen friendly semantic-release PRs Welcome Dependabot

Dependencies

$ nvm install
$ npm install

Verification

$ npm test
1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0

6 years ago

1.0.0-beta

6 years ago