本文整理汇总了TypeScript中bunyan-log.Logger类的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger类的具体用法?TypeScript Logger怎么用?TypeScript Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: express
database.connect().then((success) => {
if (success === true) {
log.info('database connected');
try {
// setup express application and middlewares
const app: express.Application = express();
container.registerInstance(express, app);
container.registerTransient(Router);
app.use(compression());
app.use(helmet());
app.use(requestHandlers.headersToLower);
app.use(requestHandlers.remoteAddressAppender);
// TODO: configure cors correctly for security concerns
app.use(cors());
// add necessary headers
app.use((req, res, next) => {
res.header('Content-*', '*');
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', '0');
next();
});
app.use(queryHandlers.toLower);
app.use(bodyParser.json({ type: '*/json', limit: '1Mb' }));
app.set(PORT_KEY, appConfig.server.port || DEFAULT_PORT);
// fulfil pre-flight promise request
app.options('*', (req, res) => {
if (appConfig.server.allowPreFlightRequest === true) {
res.status(StatusCodes.OK).json({
success: true
});
} else {
res.status(StatusCodes.FORBIDDEN).json({
success: false
});
}
});
if (appConfig.server.enableTestEndpoint === true) {
app.get('/api/test', (req, res) => {
res.json({
message: 'hello beowulf'
});
});
}
// START SERVICES HERE
const svcManager: ServiceManager = container.get(ServiceManager);
svcManager.startServices();
app.use(express.static(path.join(__dirname, PUBLIC_DIRECTORY)));
// notify of bad request
const requestLogger = new requestHandlers.RequestLogger(log);
app.use(requestLogger.unhandled);
// log unhandled errors
const errorLogger = new errorHandlers.ErrorMiddleware(log);
app.use(errorLogger.log);
const httpServer: Server = app.listen(app.get('port'), (error: Error) => {
if (error != null) {
log.error(error);
} else {
log.info('server listening over insecure http on port ' + app.get(PORT_KEY));
// we have to start active platforms
log.info('starting active platforms');
}
});
} catch (ex) {
(log as any).fatal(ex, 'fatal error in server start up');
database.close();
process.exit(1);
}
} else {
log.error('database connection failed');
return;
}
}).catch((err) => {
开发者ID:weagle08,项目名称:node-start,代码行数:89,代码来源:server.ts
示例2:
const httpServer: Server = app.listen(app.get('port'), (error: Error) => {
if (error != null) {
log.error(error);
} else {
log.info('server listening over insecure http on port ' + app.get(PORT_KEY));
// we have to start active platforms
log.info('starting active platforms');
}
});
开发者ID:weagle08,项目名称:node-start,代码行数:11,代码来源:server.ts
注:本文中的bunyan-log.Logger类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论