Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Latest commit

 

History

History
69 lines (54 loc) · 1.98 KB

README.md

File metadata and controls

69 lines (54 loc) · 1.98 KB

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