@ehosick/structured-messaging
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

structured-messaging

NOTE: In Beta.

GitHub license npm codecov

Fully configurable structured messaging and logging tool wrapping Winston. Recommended to be used in conjunction with config-core.

Motivation

Quickly get up and running with structured logging/messaging without being too opinionated.

We highly suggest using this library in conjunction with config-core.

Quick Start

Checkout the typescript examples.

Usage

import StructuredMessaging from 'structured-messaging';

let currentMessage = 0;

const logger = new StructuredMessaging(
  // use any winston parameters
  // see (https://github.com/winstonjs/winston#creating-your-own-logger)
  {
    level: 'info',
    // configure transports
    transport: [
      { type: 'console' },
      {
        type: 'file',
        // use any winston transport options for the given transport
        options: { filename: 'error_01.log', level: 'error' },
      },
    ],
    sharedData: {
      count: () => {
        currentMessage += 1;
        return currentMessage;
      },
    },
  },
).loggers();

logger.info('This is log message number %{count}.');
logger.info('This is log message number %{count}.');

// setup the logger

Package Sidebar

Install

npm i @ehosick/structured-messaging

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

27.9 kB

Total Files

6

Last publish

Collaborators

  • erichosick