@ehosick/structured-messaging
v1.0.5
Published
Enable config-core configuration and settings to load from yaml files.
Downloads
3
Maintainers
Readme
structured-messaging
NOTE: In Beta.
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