• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.logging.IndentLogger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular-devkit/core.logging.IndentLogger的典型用法代码示例。如果您正苦于以下问题:TypeScript logging.IndentLogger类的具体用法?TypeScript logging.IndentLogger怎么用?TypeScript logging.IndentLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了logging.IndentLogger类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

export default async function(options: { testing?: boolean, cliArgs: string[] }) {
  const commands = loadCommands();

  const logger = new logging.IndentLogger('cling');
  let loggingSubscription;
  if (!options.testing) {
    loggingSubscription = initializeLogging(logger);
  }

  let projectDetails = getProjectDetails();
  if (projectDetails === null) {
    projectDetails = { root: process.cwd() };
  }
  const context = {
    project: projectDetails,
  };

  try {
    const maybeExitCode = await runCommand(commands, options.cliArgs, logger, context);
    if (typeof maybeExitCode === 'number') {
      console.assert(Number.isInteger(maybeExitCode));

      return maybeExitCode;
    }

    return 0;
  } catch (err) {
    if (err instanceof Error) {
      logger.fatal(err.message);
      if (err.stack) {
        logger.fatal(err.stack);
      }
    } else if (typeof err === 'string') {
      logger.fatal(err);
    } else if (typeof err === 'number') {
      // Log nothing.
    } else {
      logger.fatal('An unexpected error occured: ' + JSON.stringify(err));
    }

    if (options.testing) {
      debugger;
      throw err;
    }

    if (loggingSubscription) {
      loggingSubscription.unsubscribe();
    }

    return 1;
  }
}
开发者ID:fmalcher,项目名称:angular-cli,代码行数:52,代码来源:index.ts


示例2: function

export default async function(options: any) {
  // ensure the environemnt variable for dynamic paths
  process.env.PWD = path.normalize(process.env.PWD || process.cwd());
  process.env.CLI_ROOT = process.env.CLI_ROOT || path.resolve(__dirname, '..', '..');

  const commands = loadCommands();

  const logger = new logging.IndentLogger('cling');
  let loggingSubscription;
  if (!options.testing) {
    loggingSubscription = initializeLogging(logger);
  }
  const context = {
    project: Project.projectOrnullProject(undefined, undefined),
  };

  try {
    const maybeExitCode = await runCommand(commands, options.cliArgs, logger, context);
    if (typeof maybeExitCode === 'number') {
      console.assert(Number.isInteger(maybeExitCode));

      return maybeExitCode;
    }

    return 0;
  } catch (err) {
    if (err instanceof Error) {
      logger.fatal(err.message);
      logger.fatal(err.stack);
    } else if (typeof err === 'string') {
      logger.fatal(err);
    } else if (typeof err === 'number') {
      // Log nothing.
    } else {
      logger.fatal('An unexpected error occured: ' + JSON.stringify(err));
    }

    if (options.testing) {
      debugger;
      throw err;
    }

    loggingSubscription.unsubscribe();
    return 1;
  }
}
开发者ID:nickroberts,项目名称:angular-cli,代码行数:46,代码来源:index.ts


示例3:

export const defaultReporter = (logger: logging.Logger): BenchmarkReporter => (process, groups) => {
  const toplevelLogger = logger;
  const indentLogger = new logging.IndentLogger('benchmark-indent-logger', toplevelLogger);

  const formatMetric = (metric: Metric | AggregatedMetric) => tags.oneLine`
    ${metric.name}: ${metric.value.toFixed(2)} ${metric.unit}
    ${metric.componentValues ? `(${metric.componentValues.map(v => v.toFixed(2)).join(', ')})` : ''}
  `;

  groups.forEach(group => {
    toplevelLogger.info(`${group.name}`);
    group.metrics.forEach(metric => indentLogger.info(formatMetric(metric)));
  });
};
开发者ID:DevIntent,项目名称:angular-cli,代码行数:14,代码来源:default-reporter.ts


示例4: function

export default async function(options: { testing?: boolean, cliArgs: string[] }) {
  const logger = new logging.IndentLogger('cling');
  let loggingSubscription;
  if (!options.testing) {
    loggingSubscription = initializeLogging(logger);
  }

  let projectDetails = getWorkspaceDetails();
  if (projectDetails === null) {
    const [, localPath] = getWorkspaceRaw('local');
    if (localPath !== null) {
      logger.fatal(`An invalid configuration file was found ['${localPath}'].`
                 + ' Please delete the file before running the command.');

      return 1;
    }

    projectDetails = { root: process.cwd() };
  }

  try {
    const maybeExitCode = await runCommand(options.cliArgs, logger, projectDetails);
    if (typeof maybeExitCode === 'number') {
      console.assert(Number.isInteger(maybeExitCode));

      return maybeExitCode;
    }

    return 0;
  } catch (err) {
    if (err instanceof Error) {
      logger.fatal(err.message);
      if (err.stack) {
        logger.fatal(err.stack);
      }
    } else if (typeof err === 'string') {
      logger.fatal(err);
    } else if (typeof err === 'number') {
      // Log nothing.
    } else {
      logger.fatal('An unexpected error occurred: ' + JSON.stringify(err));
    }

    if (options.testing) {
      debugger;
      throw err;
    }

    if (loggingSubscription) {
      loggingSubscription.unsubscribe();
    }

    return 1;
  }
}
开发者ID:cexbrayat,项目名称:angular-cli,代码行数:55,代码来源:index.ts


示例5: minimist

import { logging } from '@angular-devkit/core';
import chalk from 'chalk';
import * as minimist from 'minimist';

import {filter} from 'rxjs/operators';


const { bold, red, yellow, white } = chalk;

const argv = minimist(process.argv.slice(2), {
  boolean: ['verbose']
});

const rootLogger = new logging.IndentLogger('cling');

rootLogger
  .pipe(filter(entry => (entry.level != 'debug' || argv['verbose'])))
  .subscribe(entry => {
    let color: (s: string) => string = white;
    let output = process.stdout;
    switch (entry.level) {
      case 'info': color = white; break;
      case 'warn': color = yellow; break;
      case 'error': color = red; output = process.stderr; break;
      case 'fatal': color = (x: string) => bold(red(x)); output = process.stderr; break;
    }

    output.write(color(entry.message) + '\n');
  });

rootLogger
开发者ID:nickroberts,项目名称:angular-cli,代码行数:31,代码来源:main.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.logging.Logger类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.json类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap