本文整理汇总了TypeScript中hapi.Server.log方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Server.log方法的具体用法?TypeScript Server.log怎么用?TypeScript Server.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hapi.Server
的用法示例。
在下文中一共展示了Server.log方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
console.error = function(message: string, arg2?: string) {
if (arg2) {
base_server.log(LOG_TAGS.EXCEPTION, "console.log called with second " +
"argument from : " + (new Error().stack) + "\n Pass single argument.");
message += JSON.stringify(arg2);
}
base_server.log(LOG_TAGS.EXCEPTION, "console.error called from: " +
(new Error().stack) + "\nUse server.log() instead.");
base_server.log(LOG_TAGS.EXCEPTION, message);
};
示例2:
server.start((err) => {
if (err) {
throw err;
}
server.log('info', 'Server running at: ' + server.info.uri);
});
示例3:
// From https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp
import * as Hapi from 'hapi';
const server = new Hapi.Server();
server.connection({ port: 80 });
server.on('log', (event, tags) => {
if (tags.error) {
console.log(event);
}
});
server.log(['test', 'error'], 'Test event');
示例4:
const log: Server['log'] = (
tags: string | string[],
data?: string | object | (() => any),
timestamp?: number
) => server.log(tags, data, timestamp);
示例5: next
options.client.on('ready', () => {
server.log(['redis', 'info'], 'Redis Client connection created');
options.client.removeListener('error', initialErrorHandler);
options.client.on('error', defaultErrorHandler);
next();
});
示例6: defaultErrorHandler
function defaultErrorHandler(err) {
server.log(['redis', 'error'], err.message);
}
示例7:
.then( nDeleted =>
server.log(
['info', 'GC'],
'Session GC has run,' + nDeleted + ' expired sessions removed'
)