Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Add verbose logging flag #508

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ resolve: {
No logging from the checker. Please note that this option disables async error reporting because
this option bans `console.log()` usage.

### verbose *(boolean) (default=false)*

Enable verbose logging. Log more than just errors (e.g. typescript path, execution time).

### compiler *(string) (default='typescript')*

Allows use of TypeScript compilers other than the official one. Must be
Expand Down
4 changes: 1 addition & 3 deletions src/checker/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,7 @@ function createChecker(receive: (cb: (msg: Req) => void) => void, send: (msg: Re
}

function processDiagnostics({ seq }: Diagnostics.Request) {
let silent = !!loaderConfig.silent;

if (!silent) {
if (loaderConfig.verbose) {
console.log(colors.cyan(`\n[${instanceName}] Checking started in a separate process...`));
}

Expand Down
5 changes: 3 additions & 2 deletions src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function ensureInstance(
context
);

if (!loaderConfig.silent) {
if (loaderConfig.verbose) {
const sync = watching === WatchMode.Enabled ? ' (in a forked process)' : '';
console.log(`\n[${instanceName}] Using typescript@${compilerInfo.compilerVersion} from ${compilerInfo.compilerPath} and `
+ `"tsconfig.json" from ${configFilePath}${sync}.\n`);
Expand Down Expand Up @@ -437,6 +437,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) {
const watchMode = isWatching(compilation.compiler);
const instance: Instance = resolveInstance(compilation.compiler, instanceName);
const silent = instance.loaderConfig.silent;
const verbose = instance.loaderConfig.verbose;
const asyncErrors = watchMode === WatchMode.Enabled && !silent;

let emitError = (msg) => {
Expand All @@ -462,7 +463,7 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) {
? Promise.resolve()
: instance.checker.getDiagnostics()
.then(diags => {
if (!silent) {
if (verbose) {
if (diags.length) {
console.error(colors.red(`\n[${instanceName}] Checking finished with ${diags.length} errors`));
} else {
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface LoaderConfig {
babelOptions?: any;
usePrecompiledFiles?: boolean;
silent?: boolean;
verbose?: boolean;
useCache?: boolean;
cacheDirectory?: string;
entryFileIsJs?: boolean;
Expand Down