feat(compiler-cli): ngcc - make logging more configurable (#29591)

This allows CLI usage to filter excessive log messages
and integrations like webpack plugins to provide their own logger.

// FW-1198

PR Close #29591
This commit is contained in:
Pete Bacon Darwin
2019-03-29 10:13:14 +00:00
committed by Jason Aden
parent 39345b6fae
commit 8d3d75e454
31 changed files with 544 additions and 311 deletions

View File

@ -10,6 +10,7 @@ import * as path from 'canonical-path';
import * as yargs from 'yargs';
import {mainNgcc} from './src/main';
import {ConsoleLogger, LogLevel} from './src/logging/console_logger';
// CLI entry point
if (require.main === module) {
@ -39,9 +40,14 @@ if (require.main === module) {
})
.option('first-only', {
describe:
'If specified then only the first matching package.json property will be compiled',
'If specified then only the first matching package.json property will be compiled.',
type: 'boolean'
})
.option('l', {
alias: 'loglevel',
describe: 'The lowest severity logging message that should be output.',
choices: ['debug', 'info', 'warn', 'error'],
})
.help()
.parse(args);
@ -54,9 +60,15 @@ if (require.main === module) {
const propertiesToConsider: string[] = options['p'];
const targetEntryPointPath = options['t'] ? options['t'] : undefined;
const compileAllFormats = !options['first-only'];
const logLevel = options['l'] as keyof typeof LogLevel;
try {
mainNgcc(
{basePath: baseSourcePath, propertiesToConsider, targetEntryPointPath, compileAllFormats});
mainNgcc({
basePath: baseSourcePath,
propertiesToConsider,
targetEntryPointPath,
compileAllFormats,
logger: new ConsoleLogger(LogLevel[logLevel]),
});
process.exitCode = 0;
} catch (e) {
console.error(e.stack || e.message);