1.0.1 • Published 5 years ago
pino-stackdriver-mapper v1.0.1
@binxhealth/pino-stackdriver
A utility that makes express-pino logs StackDriver-compatible
Installation
yarn add @binxhealth/pino-stackdriver --devUsage
node server.js | npx pino-stackdriverOr with a global install:
node server.js | pino-stackdriverOr create a new stream and pass it to pino
import pino from 'pino';
import { createStream } from '@binxhealth/pino-stackdriver';
const logger = pino(
{
level: 'debug',
},
createStream()
);
logger.info('This works the same as usual...');
logger.error('...and will log to stdout with the correct Stackdriver format');API
createStream([destination]) => Pumpify
The exported createStream function takes one optional argument, destination and
returns a pumpify instance.
destination (WritableStream | SonicBoom)
Default: process.stdout
The destination parameter, at a minimum must be an object with a write method.
An ordinary Node.js stream can be passed as the destination (such as the result
of fs.createWriteStream).
For peak log writing performance it is strongly
recommended to use pino.destination or pino.extreme to create the destination file stream.
import pino from 'pino';
import { createStream } from '@binxhealth/pino-stackdriver';
// process.stdout by default
const stdoutLogger = pino({}, createStream());
// write the stream to a file
const fileLogger = pino({}, createStream(pino.destination('/log/path')));