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