Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for log level #1055

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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