Skip to content

Commit

Permalink
Add log level option (parcel-bundler#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaisueper authored and devongovett committed Mar 24, 2018
1 parent 96f1e4a commit fc041d0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Bundler extends EventEmitter {
? false
: typeof options.hmr === 'boolean' ? options.hmr : watch,
https: options.https || false,
logLevel: typeof options.logLevel === 'number' ? options.logLevel : 3,
logLevel: isNaN(options.logLevel) ? 3 : options.logLevel,
mainFile: this.mainFile,
hmrPort: options.hmrPort || 0,
rootDir: Path.dirname(this.mainFile),
Expand Down
4 changes: 3 additions & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Logger {

setOptions(options) {
this.logLevel =
options && typeof options.logLevel === 'number' ? options.logLevel : 3;
options && isNaN(options.logLevel) === false
? Number(options.logLevel)
: 3;
this.color =
options && typeof options.color === 'boolean'
? options.color
Expand Down
15 changes: 15 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ program
/^(node|browser|electron)$/
)
.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])$/
)
.action(bundle);

program
Expand Down Expand Up @@ -86,6 +91,11 @@ program
'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"',
/^(node|browser|electron)$/
)
.option(
'--log-level <level>',
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
/^([0-3])$/
)
.action(bundle);

program
Expand Down Expand Up @@ -115,6 +125,11 @@ program
'--detailed-report',
'print a detailed build report after a completed build'
)
.option(
'--log-level <level>',
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
/^([0-3])$/
)
.action(bundle);

program
Expand Down

0 comments on commit fc041d0

Please sign in to comment.