How to use the @mojaloop/central-services-shared.Logger.debug function in @mojaloop/central-services-shared

To help you get started, we’ve selected a few @mojaloop/central-services-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mojaloop / central-ledger / src / handlers / lib / kafka / cron.js View on Github external
try {
    participantNamesList = await DAO.retrieveAllParticipants()
  } catch (err) {
    Logger.error(`lib.Kafka.Cron.registerNewHandlers is unable to retrieve new participants: ${err}`)
  }
  if (participantNamesList && Array.isArray(participantNamesList)) {
    for (let participantName of participantNamesList) {
      // lets check to see if there is a Prepare Consumer for this partiticipant
      let kafkaPrepareTopic = Utility.transformAccountToTopicName(participantName, TransferEventType.TRANSFER, TransferEventAction.PREPARE)
      let isConsumerForPrepareTopicExist = false
      try {
        if (Consumer.getConsumer(kafkaPrepareTopic)) {
          isConsumerForPrepareTopicExist = true
        }
      } catch (err) {
        Logger.debug(`lib.Kafka.Cron.registerNewHandlers - participant ${participantName} for topic ${kafkaPrepareTopic} does not exist: ${err}`)
        isConsumerForPrepareTopicExist = false
      }

      if (!isConsumerForPrepareTopicExist) {
        Logger.info(`lib.Kafka.Cron.registerNewHandlers - Registering new PrepareHandler for participant ${participantName} for topic ${kafkaPrepareTopic} `)
        const RegisterHandlers = require('../../register')
        await RegisterHandlers.transfers.registerPrepareHandlers([participantName])
      }
    }
  } else {
    Logger.error(`lib.Kafka.Cron.registerNewHandlers - participantNamesList not a valid list. Skipping job for handlerType: ${handlerType}.`)
  }
}
github mojaloop / central-ledger / src / handlers / lib / kafka / consumer.js View on Github external
const isConnected = async topicName => {
  const consumer = getConsumer(topicName)

  const metadata = await getMetadataPromise(consumer, topicName)
  const foundTopics = metadata.topics.map(topic => topic.name)
  if (foundTopics.indexOf(topicName) === -1) {
    Logger.debug(`Connected to consumer, but ${topicName} not found.`)
    throw new Error(`Connected to consumer, but ${topicName} not found.`)
  }

  return true
}