0.0.1 • Published 3 years ago

hato-logging-plugin v0.0.1

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

hato-logging-plugin

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:

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

Getting Started

Import the package

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

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

const MyLogger = new Logging(console.log);

Construct a new client including the logging plugin

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

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