0.1.0 • Published 3 years ago

@gxyz/data.formats v0.1.0

Weekly downloads
-
License
Unlicense
Repository
github
Last release
3 years ago

@gxyz/data.formats

@gxyz/data.formats is a collection of data logging formats for use with Winston.

Installation

Install the module locally via your favorite npm client, like npm:

npm install @gxyz/data.formats

or yarn:

yarn add @gxyz/data.formats

Usage

mustache

Use Mustache.js as template system to format logs’s display.

You can use this format from the main entrance:

const {mustache,} = require('@gxyz/data.formats');

Or from the custom sub-path ./mustache:

const mustache = require('@gxyz/data.formats/mustache');

Using this path is not recommended:

const mustache = require('@gxyz/data.formats/lib/mustache');
const mustache = require('@gxyz/logger.format.mustache');

const logger = winston.createLogger({
  format: mustache({
    source: require.resolve('./tpl.mustache'),
  }),
});

mustache format accepts the following config props:

  • source prop of type String that points to Mustache filename or Mustache template. Please consider using require.resolve to point to a filename.
  • All remaining props of config will be considered part of view obj (take a look at Mustache.js docs).

Credits

Aziz Da
Aziz Da

License

Unlicense