Home

Awesome

Studio Log Format

🎩 Transform streams to format Studio Log streams

This module also works in the browser using a naive stream shim for small Browserify bundles.

Usage

const FancyFormat = require('@studio/log-format/fancy');

require('@studio/log')
  .pipe(new FancyFormat())
  .pipe(process.stdout);

Install

❯ npm i @studio/log-format

API

Transform Streams

Some advanced formatting is applied by naming conventions on top level properties of the data object.

These options can be passed to the bundled format transforms:

The stack option is also used to format the "cause", if present.

Writable Streams

Custom Format Transforms

You can also write your own format transforms by implementing a node transform streams in writableObjectMode. Here is an example transform implementation, similar to the ndjson transform for Studio Log:

const { Transform } = require('stream');

const ndjson = new Transform({
  writableObjectMode: true,

  transform(entry, enc, callback) {
    const str = JSON.stringify(entry);
    callback(null, `${str}\n`);
  }
});

Related modules

License

MIT

<div align="center">Made with ❤️ on 🌍</div>