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


TypeScript core.logging.IndentLogger類代碼示例

本文整理匯總了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;未經允許,請勿轉載。