本文整理匯總了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)
})