當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。