Skip to content

Commit fc041d0

Browse files
nicolaisueperdevongovett
authored andcommitted
Add log level option (#1055)
1 parent 96f1e4a commit fc041d0

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/Bundler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Bundler extends EventEmitter {
8585
? false
8686
: typeof options.hmr === 'boolean' ? options.hmr : watch,
8787
https: options.https || false,
88-
logLevel: typeof options.logLevel === 'number' ? options.logLevel : 3,
88+
logLevel: isNaN(options.logLevel) ? 3 : options.logLevel,
8989
mainFile: this.mainFile,
9090
hmrPort: options.hmrPort || 0,
9191
rootDir: Path.dirname(this.mainFile),

src/Logger.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class Logger {
1414

1515
setOptions(options) {
1616
this.logLevel =
17-
options && typeof options.logLevel === 'number' ? options.logLevel : 3;
17+
options && isNaN(options.logLevel) === false
18+
? Number(options.logLevel)
19+
: 3;
1820
this.color =
1921
options && typeof options.color === 'boolean'
2022
? options.color

src/cli.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ program
5151
/^(node|browser|electron)$/
5252
)
5353
.option('-V, --version', 'output the version number')
54+
.option(
55+
'--log-level <level>',
56+
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
57+
/^([0-3])$/
58+
)
5459
.action(bundle);
5560

5661
program
@@ -86,6 +91,11 @@ program
8691
'set the runtime environment, either "node", "browser" or "electron". defaults to "browser"',
8792
/^(node|browser|electron)$/
8893
)
94+
.option(
95+
'--log-level <level>',
96+
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
97+
/^([0-3])$/
98+
)
8999
.action(bundle);
90100

91101
program
@@ -115,6 +125,11 @@ program
115125
'--detailed-report',
116126
'print a detailed build report after a completed build'
117127
)
128+
.option(
129+
'--log-level <level>',
130+
'set the log level, either "0" (no output), "1" (errors), "2" (warnings + errors) or "3" (all).',
131+
/^([0-3])$/
132+
)
118133
.action(bundle);
119134

120135
program

0 commit comments

Comments
 (0)