Skip to content
Merged
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
6 changes: 3 additions & 3 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ class Bundler extends EventEmitter {
this.entryAssets.add(asset);
} catch (err) {
throw new Error(
`Cannot resolve entry "${entry}" from "${
this.options.rootDir
}"`
`Cannot resolve entry "${entry}" from "${this.options.rootDir}"`
);
}
}
Expand Down Expand Up @@ -602,6 +600,8 @@ class Bundler extends EventEmitter {
}
});

logger.verbose(`Built ${asset.relativeName}...`);

if (this.cache && cacheMiss) {
this.cache.write(asset.name, processed);
}
Expand Down
33 changes: 32 additions & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const {countBreaks} = require('grapheme-breaker');
const stripAnsi = require('strip-ansi');
const ora = require('ora');
const WorkerFarm = require('./workerfarm/WorkerFarm');
const path = require('path');
const fs = require('fs');

class Logger {
constructor(options) {
Expand Down Expand Up @@ -50,6 +52,10 @@ class Logger {
}

write(message, persistent = false) {
if (this.logLevel > 3) {
return this.verbose(message);
}

if (!persistent) {
this.lines += this.countLines(message);
}
Expand All @@ -58,6 +64,27 @@ class Logger {
this._log(message);
}

verbose(message) {
if (this.logLevel < 4) {
return;
}

let currDate = new Date();
message = `[${currDate.toLocaleTimeString()}]: ${message}`;
if (this.logLevel > 4) {
if (!this.logFile) {
this.logFile = fs.createWriteStream(
path.join(
process.cwd(),
`parcel-debug-${currDate.toLocaleDateString()}@${currDate.toLocaleTimeString()}.log`
)
);
}
this.logFile.write(stripAnsi(message) + '\n');
}
this._log(message);
}

log(message) {
if (this.logLevel < 3) {
return;
Expand Down Expand Up @@ -103,7 +130,7 @@ class Logger {
}

clear() {
if (!this.color || this.isTest) {
if (!this.color || this.isTest || this.logLevel > 3) {
return;
}

Expand All @@ -122,6 +149,10 @@ class Logger {
return;
}

if (this.logLevel > 3) {
return this.verbose(message);
}

let styledMessage = this.chalk.gray.bold(message);
if (!this.spinner) {
this.spinner = ora({
Expand Down
12 changes: 6 additions & 6 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ program
.option('-V, --version', 'output the version number')
.option(
'--log-level <level>',
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
/^([0-3])$/
'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).',
/^([0-5])$/
)
.option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"')
.action(bundle);
Expand Down Expand Up @@ -107,8 +107,8 @@ program
)
.option(
'--log-level <level>',
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
/^([0-3])$/
'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).',
/^([0-5])$/
)
.option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"')
.action(bundle);
Expand Down Expand Up @@ -151,8 +151,8 @@ program
)
.option(
'--log-level <level>',
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
/^([0-3])$/
'set the log level, either "0" (no output), "1" (errors), "2" (warnings), "3" (info), "4" (verbose) or "5" (debug, creates a log file).',
/^([0-5])$/
)
.option('--cache-dir <path>', 'set the cache directory. defaults to ".cache"')
.action(bundle);
Expand Down