How to use the @mojaloop/central-services-shared.Logger.info 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 / domain / settlement / index.js View on Github external
const creditKey = settledFee.payeeParticipantName
      if (key === debitKey || key === creditKey) {
        feeArray.push(settledFee)
      }
    })
    Logger.info('iterating map' + key)
    const joinedSettlementJson = csv.joinedSettlementJson(csv.flattenedTransfersJson(value), csv.flattenedFeeJson(feeArray))
    const keys = csv.keys(joinedSettlementJson)
    const csvFile = csv.convertJsonToCsv(joinedSettlementJson, keys)
    const mailInformation = {
      csvFile: csvFile,
      email: String
    }
    // const participant = ParticipantDatabase.getByName(key).catch(participant)
    mailInformation.email = 'modusboxemailtest@gmail.com' // this will change to email once nico has the email in database
    Logger.info('calling email')
    Events.emailSettlementCsv(mailInformation)
  }
}
github mojaloop / central-ledger / src / handlers / lib / kafka / cron.js View on Github external
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 / admin / auth / admin.js View on Github external
const validate = async (request, username, password, h) => {
  if (!(username && password && Config.ADMIN_KEY && Config.ADMIN_SECRET)) {
    return {credentials: null, isValid: false}
  }
  const isValid = password === Config.ADMIN_SECRET
  // const isValid = await Bcrypt.compare(password, Config.ADMIN_SECRET) to be used in the future to hash passwords
  if (username === Config.ADMIN_KEY && isValid) {
    const credentials = {id: 'test', name: username, is_admin: true}
    Logger.info('is a valid admin')
    return {isValid: true, credentials}
  } else {
    return {credentials: null, isValid: false}
  }
}
github mojaloop / central-ledger / src / handlers / lib / kafka / producer.js View on Github external
const produceMessage = async (messageProtocol, topicConf, config) => {
  try {
    let producer
    if (listOfProducers[topicConf.topicName]) {
      producer = listOfProducers[topicConf.topicName]
    } else {
      Logger.info('Producer::start::topic=' + topicConf.topicName)
      producer = new Producer(config)
      Logger.info('Producer::connect::start')
      await producer.connect()
      Logger.info('Producer::connect::end')
      listOfProducers[topicConf.topicName] = producer
    }
    Logger.info(`Producer.sendMessage::messageProtocol:'${JSON.stringify(messageProtocol)}'`)
    await producer.sendMessage(messageProtocol, topicConf)
    Logger.info('Producer::end')
    return true
  } catch (err) {
    Logger.error(err)
    throw ErrorHandler.Factory.createInternalServerFSPIOPError(`Producer error has occurred for ${topicConf.topicName}`, err)
  }
}
github mojaloop / central-ledger / src / lib / mongodb.js View on Github external
Mongoose.connection.once('open', function callback () {
  Logger.info('MongoDB succesfully connected')
})
github mojaloop / central-ledger / src / handlers / lib / kafka / consumer.js View on Github external
const createHandler = async (topicName, config, command) => {
  Logger.info(`CreateHandle::connect - creating Consumer for topics: [${topicName}]`)

  let topicNameArray
  if (Array.isArray(topicName)) {
    topicNameArray = topicName
  } else {
    topicNameArray = [topicName]
  }

  const consumer = new Consumer(topicNameArray, config)

  let autoCommitEnabled = true
  if (config.rdkafkaConf !== undefined && config.rdkafkaConf['enable.auto.commit'] !== undefined) {
    autoCommitEnabled = config.rdkafkaConf['enable.auto.commit']
  }

  let connectedTimeStamp = 0
github mojaloop / central-ledger / src / domain / settlement / index.js View on Github external
const mailDetails = (settledTransfers, settledFee) => {
  var settledTransfersMap
  Logger.info('Entering transfers')
  settledTransfersMap = transfersMap(settledTransfers)
  Logger.info('out of map')
  for (const [key, value] of settledTransfersMap.entries()) {
    const feeArray = []
    settledFee.forEach(settledFee => {
      const debitKey = settledFee.payerParticipantName
      const creditKey = settledFee.payeeParticipantName
      if (key === debitKey || key === creditKey) {
        feeArray.push(settledFee)
      }
    })
    Logger.info('iterating map' + key)
    const joinedSettlementJson = csv.joinedSettlementJson(csv.flattenedTransfersJson(value), csv.flattenedFeeJson(feeArray))
    const keys = csv.keys(joinedSettlementJson)
    const csvFile = csv.convertJsonToCsv(joinedSettlementJson, keys)
    const mailInformation = {
github mojaloop / central-ledger / src / handlers / lib / kafka / producer.js View on Github external
const produceMessage = async (messageProtocol, topicConf, config) => {
  try {
    let producer
    if (listOfProducers[topicConf.topicName]) {
      producer = listOfProducers[topicConf.topicName]
    } else {
      Logger.info('Producer::start::topic=' + topicConf.topicName)
      producer = new Producer(config)
      Logger.info('Producer::connect::start')
      await producer.connect()
      Logger.info('Producer::connect::end')
      listOfProducers[topicConf.topicName] = producer
    }
    Logger.info(`Producer.sendMessage::messageProtocol:'${JSON.stringify(messageProtocol)}'`)
    await producer.sendMessage(messageProtocol, topicConf)
    Logger.info('Producer::end')
    return true
  } catch (err) {
    Logger.error(err)
    throw ErrorHandler.Factory.createInternalServerFSPIOPError(`Producer error has occurred for ${topicConf.topicName}`, err)
  }
}
github mojaloop / central-ledger / src / domain / settlement / settlementEventListener.js View on Github external
transporter.sendMail(mailOptions, function (error, info) {
      if (error) {
        return Logger.error(error)
      }
      Logger.info('Message sent: ' + info.response)
    })
  }
github mojaloop / central-ledger / src / handlers / lib / kafka / producer.js View on Github external
const produceMessage = async (messageProtocol, topicConf, config) => {
  try {
    let producer
    if (listOfProducers[topicConf.topicName]) {
      producer = listOfProducers[topicConf.topicName]
    } else {
      Logger.info('Producer::start::topic=' + topicConf.topicName)
      producer = new Producer(config)
      Logger.info('Producer::connect::start')
      await producer.connect()
      Logger.info('Producer::connect::end')
      listOfProducers[topicConf.topicName] = producer
    }
    Logger.info(`Producer.sendMessage::messageProtocol:'${JSON.stringify(messageProtocol)}'`)
    await producer.sendMessage(messageProtocol, topicConf)
    Logger.info('Producer::end')
    return true
  } catch (err) {
    Logger.error(err)
    throw ErrorHandler.Factory.createInternalServerFSPIOPError(`Producer error has occurred for ${topicConf.topicName}`, err)
  }
}