當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Logger.error方法代碼示例

本文整理匯總了TypeScript中pino.Logger.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Logger.error方法的具體用法?TypeScript Logger.error怎麽用?TypeScript Logger.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pino.Logger的用法示例。


在下文中一共展示了Logger.error方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: validateAttendeeBySlackId

async function validateAttendeeBySlackId(username: string, slack: WebClient, log: Logger) {
  if (!slackIdPattern.test(username)) {
    log.info(`Invalid slackid: "${username}"`)
    return null
  }

  log.info(`Finding attendee with slackid "${username}"...`)

  const attendee = await AttendeeModel
    .findOne({ slackid: username }, '_id attendeeid')
    .exec()

  if (attendee !== null) {
    log.info(`Found attendee "${username}" to be "${attendee.attendeeid}`)
    return { username: attendee.attendeeid }
  }

  log.info(`Looking up Slack profile for attendee "${username}"...`)

  let slackUser: UsersInfoResponse
  try {
    slackUser = await slack.users.info(username)
  } catch (err) {
    log.error(`Could not look-up user "${username}" on Slack API: ${err.message}`)
    return null
  }

  log.info(`Found "${username}" to be "${slackUser.user.profile.email}"`)

  const updateResponse = await AttendeeModel
    .findOneAndUpdate({ attendeeid: slackUser.user.profile.email }, { slackid: slackUser.user.id })
    .select('_id')
    .exec()

  if (updateResponse === null) {
    return null
  }

  return { username: slackUser.user.profile.email }
}
開發者ID:TechNottingham,項目名稱:Hack24-API,代碼行數:40,代碼來源:attendee-auth-strategy.ts

示例2:

 this._pusher.trigger('api_events', event, data, null, (err) => {
   if (err) {
     logger.error(`Unable to send event to pusher: ${err.message}`)
   }
 })
開發者ID:TechNottingham,項目名稱:Hack24-API,代碼行數:5,代碼來源:eventbroadcaster.ts


注:本文中的pino.Logger.error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。