本文整理汇总了TypeScript中@sample-stack/utils.logger.info方法的典型用法代码示例。如果您正苦于以下问题:TypeScript logger.info方法的具体用法?TypeScript logger.info怎么用?TypeScript logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@sample-stack/utils.logger
的用法示例。
在下文中一共展示了logger.info方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
server.listen(serverPort, () => {
logger.info(`Client Server is now running on port ${serverPort}`);
});
示例2:
server.listen(serverPort, () => {
logger.info(`API is now running on port ${serverPort}`);
});
示例3: DbConfig
import { Container } from 'inversify';
import { DbConfig, repositoryModule, TYPES as RepoTypes, ICounterRepository } from '@sample-stack/store';
import * as Hemera from 'nats-hemera';
import { pubsub, client as natsClient } from './pubsub';
import { TaggedType } from '@sample-stack/core';
import { database as DEFAULT_DB_CONFIG } from '../../../../config/development/settings.json';
import { logger } from '@sample-stack/utils';
const dbConfig = new DbConfig(DEFAULT_DB_CONFIG);
let counterRepo;
try {
let container = new Container();
container.load(repositoryModule(dbConfig));
logger.info('Running in environment : [%s]', process.env.NODE_ENV);
if (process.env.NODE_ENV === 'development') {
// development
counterRepo = container.get<ICounterRepository>(RepoTypes.ICounterRepository);
} else {
// all other environment
const hemera = new Hemera(natsClient, {
logLevel: process.env.HEMERA_LOG_LEVEL as Hemera.LogLevel || 'info',
childLogger: true,
tag: 'hemera-server',
timeout: 10000,
});
container.bind('Hemera').toConstantValue(hemera);
counterRepo = container.getNamed<ICounterRepository>(RepoTypes.ICounterRepository, TaggedType.MICROSERVICE);
}
} catch (err) {
logger.error('Server start failed when building the containers');
示例4: callback
import * as cors from 'cors';
import * as express from 'express';
import { SETTINGS } from '../config';
import { logger } from '@sample-stack/utils';
const CLIENT_URL = SETTINGS.CLIENT_URL;
const BACKEND_URL = SETTINGS.BACKEND_URL;
const corsWhitelist = [
BACKEND_URL,
CLIENT_URL,
];
logger.info('Cors whitelist: %j', corsWhitelist);
const corsOptions = {
origin: (origin, callback) => {
if (corsWhitelist.indexOf(origin) !== -1) {
callback(null, true);
} else {
// TODO: only throw when in debug mode
logger.error('url (%s) is not in the whitelist', origin);
// callback(new Error('Not allowed by CORS'))
logger.warn('allowing all origins temporarily, you need to disable it.');
callback(null, true);
}
},
credentails: false,
};
export const corsMiddleware = cors(corsOptions);