Log messages to RabbitMQ
A Winston Transport module for sending logs to RabbitMQ
This library was primarily designed to be used as a transport module for Winston logger. It can also be used as a simple utility for sending messages to RabbitMQ with minimum effort for configuration.
Installation
npm install rabbitmq-logger --save
Requires Node >= 8.3.0 to run
Usage
var winston = ;;var logger = winston;logger;
Usage as a RabbitMQ helper utility
var winston = ;;var mq = winston;moduleexports =mqmq;
Options
The module can be customized using the following options :
- name : The logger name, common option for Winston transports
- level: The logging level (debug/info/warn/error). The level name is used as the default routing key while sending to RabbitMQ. Can have custom strings if required.
- url: The RabbitMQ server url which is going to be used for creating connection. If not specified, it takes
WINSTON_RABBITMQ_URL
environment variable as the url or uses default valueamqp://localhost:5672
- socketOpts: Options that are going to used for creating connection to RabbitMQ
socketOpts: {}
- exchange: RabbitMQ Exchange that is going to be used for sending messages
- exchangeOptions: Options that are going to be used for by channel for sending messages to exchange
exchangeOptions:{}
- logToConsole: Boolean value that enables logging to console if sending messages to RabbitMQ is not required
- timestamp: By default it returns the current timestamp in ISO format. Can be overridden if required
- debug: Takes a custom function that can be used for getting debug messages from the library. Only enabled if the logging level is also set as
debug
Message Format
level: <log_level or custom_key> message: <message_body> name: <name of the logger instance> src: <system hostname>