本文整理汇总了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}`)
}
})
}
示例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();
}
});
示例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;
});
};
示例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)
}
示例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)
})