Skip to content

Commit

Permalink
refactor(ui5-service): harmonize logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vobu committed Nov 29, 2021
1 parent 9982de3 commit ff5d369
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions wdio-ui5-service/src/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// The rest of the hooks will be handled by the service (the default export), as normal.

const SevereServiceError = require('webdriverio');
const Logger = require('./lib/Logger');
const wdioUI5 = require('./lib/wdioUi5-index');

module.exports = class Service {
Expand All @@ -22,34 +20,36 @@ module.exports = class Service {
// As of version 1.72, it is available as a declarative matcher
context._oldAPIVersion = 1.6;

Logger.setLoglevel(wdi5config?.logLevel || 'error');

// this is only to run in browser
if (wdi5config && typeof wdi5config.url === 'string') {
if (wdi5config.url.length > 0) {
console.log('open url: ' + wdi5config.url);
Logger.info(`open url: ${wdi5config.url}`);
browser.url(wdi5config.url);
} else if (wdi5config.url === '') {
console.log(
Logger.info(
'open url with fallback (this is not causing any issues since its is removed for navigation): #'
);
browser.url('#');
} else {
// just for error logging
console.error('not opening any url, wdi5 config contains errors');
Logger.error('not opening any url, wdi5 config contains errors');
}
} else {
// just for error logging
console.error('not opening any url, no url was supplied in wdi5 config');
Logger.error('not opening any url, no url was supplied in wdi5 config');
}

console.log('wdio-ui5-service before hook');
Logger.info('wdio-ui5-service before hook');

wdioUI5.setup(context); // use wdio hooks for setting up wdio<->ui5 bridge

// skip UI5 initialization on startup
if (wdi5config && !wdi5config.skipInjectUI5OnStart) {
this.injectUI5();
} else {
console.log('wdio-ui5-service skipped injecting UI5');
Logger.warn('wdio-ui5-service skipped injecting UI5');
}
}

Expand Down

0 comments on commit ff5d369

Please sign in to comment.