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


TypeScript pino.Logger類代碼示例

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


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

示例1: trigger

 public trigger(event: string, data: any, logger: Logger) {
   if (!this._pusher) {
     return logger.info(`Suppressing Pusher event "${event}" for channel "api_events"`, data)
   }
   logger.info(`Sending Pusher event "${event}" to channel "api_events"`)
   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,代碼行數:11,代碼來源:eventbroadcaster.ts

示例2: it

  it('should log at log level info when LOG_LEVEL is not set', async () => {
    const restore: () => void = setupEnv('LOG_LEVEL', '');

    logger = await createLogger();

    try {
      logger.debug({ someObject: { someNesting: true } }, 'some message');
      logger.info({ someObject: { someNesting: true } }, 'some message');
      expect(stdoutSpy).toHaveBeenCalledTimes(1);
    } finally {
      restore();
    }
  });
開發者ID:akreitals,項目名稱:pino-aws-logger,代碼行數:13,代碼來源:logger.spec.ts

示例3: getBaseLogger

export const createLogger = (
  options: PinoAwsLoggerOptions = {}
): Promise<Logger> => {
  const { decorators = [], ...pinoOptions } = options;
  const logger: Logger = getBaseLogger(pinoOptions);

  return getMetadata([...decorators, ...defaultDecorators])
    .then(metadata => {
      const definedMetadata = filterUndefinedValues(metadata);
      return logger.child(definedMetadata);
    })
    .catch(() => {
      return logger;
    });
};
開發者ID:akreitals,項目名稱:pino-aws-logger,代碼行數:15,代碼來源:logger.ts

示例4: constructor

 constructor(url: string, private log: Logger) {
   if (!url) {
     this.log.warn('Pusher URL is not defined. Suppressing Pusher events.')
     return
   }
   this._pusher = Pusher.forURL(url)
 }
開發者ID:TechNottingham,項目名稱:Hack24-API,代碼行數:7,代碼來源:eventbroadcaster.ts

示例5: setTimeout

      }, (err) => {
        err.message = `Unable to connect to MongoDB - ${err.message}`

        if (attempts < MAX_RECONNECT_ATTEMPTS) {
          log.warn(err.message)
          setTimeout(connect, RECONNECT_DELAY)
          return
        }

        reject(err)
      })
開發者ID:TechNottingham,項目名稱:Hack24-API,代碼行數:11,代碼來源:database.ts


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