Easy ways to use logs and send them to RabbitMQ using menashmq in your service for TypeScript
index.ts
import logger from 'logger-genesis';
logger.initialize('systemA', 'serviceA', true, {
createMenashRabbitMQConnection: true,
uri: 'amqp://localhost:5672',
logQueueName: 'log-queue',
});
import logger from 'logger-genesis';
logger.info(title, message, JSON.stringify(extraFields));
-
initialize()
-
info()
-
warn()
-
error()
initialize
-
system -> Name of the system
-
service -> Name of the service
-
logQueueName -> Name of the Log's Queue
-
createRabbitConnection -> True if need to create connection to rabbitMQ with menash
-
uri -> Connection URI of rabbitMQ (Needed only if createRabbitConnection is true)
-
retryOptions -> retryOption to connect to RabbitMQ (details in menashmq readme, needed only if createRabbitConnection is true)
logInfo/logWarn/logError
-
title -> Title of the log
-
message -> The message of the log
-
extraFields -> Extra fields that you want to add (Like id, runUID and etc.)