1
1
export default ( SeleniumBrowser ) => {
2
2
return class extends SeleniumBrowser {
3
- setLogLevel ( level , types ) {
3
+ setLogLevel ( levels , types ) {
4
4
/* Seems only Chrome really supports browser logging
5
5
* - https://github.com/mozilla/geckodriver/issues/284
6
6
*/
@@ -14,16 +14,40 @@ export default (SeleniumBrowser) => {
14
14
}
15
15
16
16
// flush the remote logs on every call to webpage
17
- this . hook ( 'webpage:property' , ( ) => this . browser . flushLogs ( ) )
17
+ this . hook ( 'webpage:property' , ( ) => this . flushLogs ( ) )
18
18
19
19
this . hook ( 'selenium:build:before' , ( builder ) => {
20
20
const logging = SeleniumBrowser . webdriver . logging
21
21
22
+ const levelMap = {
23
+ error : logging . Level . SEVERE ,
24
+ warning : logging . Level . WARNING ,
25
+ log : logging . Level . INFO ,
26
+ info : logging . Level . FINEST ,
27
+ debug : logging . Level . DEBUG
28
+ }
29
+
30
+ if ( ! Array . isArray ( levels ) ) {
31
+ levels = [ levels ]
32
+ }
33
+
34
+ let level
35
+ for ( const key in levelMap ) {
36
+ if ( levels . includes ( key ) ) {
37
+ level = levelMap [ key ]
38
+ break
39
+ }
40
+ }
41
+
42
+ if ( ! types ) {
43
+ types = [ logging . Type . BROWSER ]
44
+ }
45
+
22
46
const prefs = new logging . Preferences ( )
23
47
24
48
for ( const key in logging . Type ) {
25
49
const type = logging . Type [ key ]
26
- if ( ! types || types . includes ( type ) ) {
50
+ if ( types . includes ( type ) ) {
27
51
prefs . setLevel ( type , level || 0 )
28
52
}
29
53
}
0 commit comments