当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript logger.info方法代码示例

本文整理汇总了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}`);
});
开发者ID:baotaizhang,项目名称:fullstack-pro,代码行数:3,代码来源:server.ts

示例2:

server.listen(serverPort, () => {
    logger.info(`API is now running on port ${serverPort}`);
});
开发者ID:baotaizhang,项目名称:fullstack-pro,代码行数:3,代码来源:api-server.ts

示例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');
开发者ID:baotaizhang,项目名称:fullstack-pro,代码行数:31,代码来源:sample-facade.ts

示例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);
开发者ID:baotaizhang,项目名称:fullstack-pro,代码行数:29,代码来源:cors.ts


注:本文中的@sample-stack/utils.logger.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。