0.0.4 • Published 2 years ago

hato-logging v0.0.4

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

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