fix(logs): WDIO_LOG_LEVEL#10167
Conversation
|
|
||
| if (!options.logLevels || !options.logLevels.webdriver) { | ||
| logger.setLevel('webdriver', params.logLevel!) | ||
| if (params.logLevel && (!options.logLevels || !options.logLevels.webdriver)) { |
|
one e2e test ("should allow to use then/catch/finally") randomly fell on windows due to |
| */ | ||
| logLevel: { | ||
| type: 'string', | ||
| default: 'info', |
There was a problem hiding this comment.
Why removing the default values?
There was a problem hiding this comment.
I mentioned above, in "proposed changes". Summary: because they have a priority over WDIO_LOG_LEVEL and are obsolete: wdio/logger can handle default value on its own.
Currently if you set WDIO_LOG_LEVEL env variable, you will still see
infolevel logs fromdevtoolsandwebdriverbecausedevtools.newSessionandwebdriver.newSessiondefaultinglogLeveltoinfo(devtools and webdriver). Though its not needed becausesetLogLevelsConfigalready sets right logLevels onwdio.remotehere, andgetLoggeralready has this fallback with default value.
There was a problem hiding this comment.
So it does not affect the behavior if WDIO_LOG_LEVEL is not set, and will use logLevel= process.env.WDIO_LOG_LEVEL if it is.
There was a problem hiding this comment.
Let's keep this anyway as it better describes the default behavior. The default log level for @wdio/logger can maybe change in the future and we would like to keep the current default in devtools and webdriver.
There was a problem hiding this comment.
Whats about
options.logLevel = process.env.WDIO_LOG_LEVEL ?? options.logLevel
const params = validateConfig(DEFAULTS, options)or
const params = validateConfig(DEFAULTS, options)
params.logLevel = process.env.WDIO_LOG_LEVEL?? options.logLevel ?? params.logLevelin devtools/src/index.ts to set priority as:
process.env.WDIO_LOG_LEVELoptions.logLevelDEFAULT
Currently DEFAULT priority is higher than process.env.WDIO_LOG_LEVEL, which makes no sense
There was a problem hiding this comment.
Fixed:
const envLogLevel = process.env.WDIO_LOG_LEVEL as Options.WebDriverLogTypes | undefined
options.logLevel = envLogLevel ?? options.logLevel
const params = validateConfig(DEFAULTS, options)validateConfig is being called after setting logLevel from process.env so we could verify it
f982dee to
292bdb7
Compare
292bdb7 to
a1135cc
Compare
Proposed changes
WDIO_LOG_LEVELenv variable.Currently if you set WDIO_LOG_LEVEL env variable, you will still see
infolevel logs fromdevtoolsandwebdriverbecausedevtools.newSessionandwebdriver.newSessiondefaultinglogLeveltoinfo(devtools and webdriver). Though its not needed becausesetLogLevelsConfigalready sets right logLevels onwdio.remotehere, andgetLoggeralready has this fallback with default value.WDIO_LOG_LEVELenv variable.Types of changes
Checklist
Reviewers: @webdriverio/project-committers