hato-logging
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

hato-logging

CircleCI Maintainability Test Coverage GitHub license

A plugin for logging messages passing through hato

About

This is a plugin for hato, an amqp framework.

This plugin facilitates logging of messages that are published and consumed by hato.

The plugin accepts a logging function to which messages will be passed as they are published and consumed. The passed logging function should accept one argument which will be passed in the following format:

{
    command, // Either 'publish' or 'consume'
    exchange,
    routingKey,
    content
}

Getting Started

Import the package

const Logging = require('hato-logging');

Instantiate the logging plugin with a logging function of your choice, if left empty the default is console.log

const MyPlugin = new Logging({
    log: (level, data, msg) => logger[level](data, msg), // example: bunyan
    body: {
        enabled: true,
        maxBytes: 10000
    }
});

Construct a new client including the logging plugin

const client = new Client(BROKER_URL, {
    plugins: [
        ...,
        MyPlugin
    ],
});

Running Tests

Make sure you have a message broker running. The tests expect RabbitMQ.

$ docker run -it --name rabbitmq -p 5672:5672 rabbitmq:3.6-alpine

Then run

$ make test
$ make lint

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i hato-logging

Weekly Downloads

42

Version

0.0.4

License

MIT

Unpacked Size

19.8 kB

Total Files

11

Last publish

Collaborators

  • openrm