0.0.1 • Published 5 years ago

@project-reporter/json-format v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Project Reporter - JSON Format

This package contains a simple TFormatFunction that convert log message into a valid JSON format.

Installation

Using NPM.

npm i @project-reporter/json-format

Using Yarn.

yarn add @project-reporter/json-format

Usage Example

import { FileReporter } from '@project-reporter/file-reporter';
import { jsonFormat } from '@project-reporter/json-format';

const reporter = new FileReporter(); // or any other logger.

reporter.setFormat(jsonFormat); // use it as a format function.

reporter.error(new Error('Something wrong'));

Example output

{
  "level": "ERROR",
  "timestamp": "2020-07-21 12:20:05",
  "message": "Something wrong",
  "stack": [
    {
      "file": "internal/bootstrap/node.js",
      "method": "bootstrapNodeJSCore",
      "line": 689,
      "column": 30
    }
    // ...
  ]
}

Contributing

See Contribution Guidelines