當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript logging.IndentLogger.pipe方法代碼示例

本文整理匯總了TypeScript中@angular-devkit/core.logging.IndentLogger.pipe方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript logging.IndentLogger.pipe方法的具體用法?TypeScript logging.IndentLogger.pipe怎麽用?TypeScript logging.IndentLogger.pipe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular-devkit/core.logging.IndentLogger的用法示例。


在下文中一共展示了logging.IndentLogger.pipe方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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
  .pipe(filter(entry => entry.level == 'fatal'))
開發者ID:nickroberts,項目名稱:angular-cli,代碼行數:32,代碼來源:main.ts


注:本文中的@angular-devkit/core.logging.IndentLogger.pipe方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。