@@ -55,7 +55,7 @@ function requireDriverProperties(driver) {
5555 */
5656async function getCandidateSocketNames ( ) {
5757 const { adb} = requireDriverProperties ( this . driver ) ;
58- this . logger . debug ( 'Getting a list of candidate devtools sockets' ) ;
58+ this . log . debug ( 'Getting a list of candidate devtools sockets' ) ;
5959 const out = await adb . shell ( [ 'cat' , '/proc/net/unix' ] ) ;
6060 const names = [ ] ;
6161 const allMatches = [ ] ;
@@ -78,12 +78,12 @@ async function getCandidateSocketNames() {
7878 names . push ( sockPath ) ;
7979 }
8080 if ( _ . isEmpty ( names ) ) {
81- this . logger . debug ( 'Found no active devtools sockets' ) ;
81+ this . log . debug ( 'Found no active devtools sockets' ) ;
8282 if ( ! _ . isEmpty ( allMatches ) ) {
83- this . logger . debug ( `Other sockets are: ${ JSON . stringify ( allMatches , null , 2 ) } ` ) ;
83+ this . log . debug ( `Other sockets are: ${ JSON . stringify ( allMatches , null , 2 ) } ` ) ;
8484 }
8585 } else {
86- this . logger . debug (
86+ this . log . debug (
8787 `Parsed ${ names . length } active devtools ${ util . pluralize ( 'socket' , names . length , false ) } : ` +
8888 JSON . stringify ( names )
8989 ) ;
@@ -109,9 +109,9 @@ async function getCandidateSocketNames() {
109109 * @returns {Promise<WebviewProps> }
110110 */
111111async function collectSingleDetails ( socketName , localPort ) {
112- this . logger . debug ( `Collecting CDP data of '${ socketName } '` ) ;
112+ this . log . debug ( `Collecting CDP data of '${ socketName } '` ) ;
113113 const [ info , pages ] = await B . all ( [ cdpInfo ( localPort ) , cdpList ( localPort ) ] ) ;
114- this . logger . info ( `Collected CDP details of '${ socketName } '` ) ;
114+ this . log . info ( `Collected CDP details of '${ socketName } '` ) ;
115115 return { info, pages} ;
116116}
117117
@@ -133,12 +133,12 @@ async function collectMultipleDetails(socketNames) {
133133 /** @type {Record<string, WebviewProps> } */
134134 const details = { } ;
135135 // Connect to each devtools socket and retrieve web view details
136- this . logger . debug ( `Collecting CDP data of ${ util . pluralize ( 'candidate webview' , socketNames . length , true ) } ` ) ;
136+ this . log . debug ( `Collecting CDP data of ${ util . pluralize ( 'candidate webview' , socketNames . length , true ) } ` ) ;
137137 const [ startPort , endPort ] = DEVTOOLS_LOOKUP_PORTS_RANGE ;
138138 let localPort ;
139139 try {
140140 localPort = await findAPortNotInUse ( startPort , endPort ) ;
141- } catch ( e ) {
141+ } catch {
142142 throw new Error (
143143 `Cannot find any free port to forward candidate Devtools sockets ` +
144144 `in range ${ startPort } ..${ endPort } `
@@ -149,7 +149,7 @@ async function collectMultipleDetails(socketNames) {
149149 try {
150150 await adb . forwardAbstractPort ( localPort , remotePort ) ;
151151 } catch ( e ) {
152- this . logger . debug (
152+ this . log . debug (
153153 `Could not create a port forward to fetch the details of '${ socketName } ' socket: ${ e . message } `
154154 ) ;
155155 continue ;
@@ -158,16 +158,16 @@ async function collectMultipleDetails(socketNames) {
158158 try {
159159 details [ socketName ] = await collectSingleDetails . bind ( this ) ( socketName , localPort ) ;
160160 } catch ( e ) {
161- this . logger . debug ( `Could not fetch the CDP details of '${ socketName } ' socket: ${ e . message } ` ) ;
161+ this . log . debug ( `Could not fetch the CDP details of '${ socketName } ' socket: ${ e . message } ` ) ;
162162 } finally {
163163 try {
164164 await adb . removePortForward ( localPort ) ;
165165 } catch ( e ) {
166- this . logger . debug ( e . message ) ;
166+ this . log . debug ( e . message ) ;
167167 }
168168 }
169169 }
170- this . logger . info ( `Collected CDP details of ${ util . pluralize ( 'webview' , _ . size ( details ) , true ) } ` ) ;
170+ this . log . info ( `Collected CDP details of ${ util . pluralize ( 'webview' , _ . size ( details ) , true ) } ` ) ;
171171 return details ;
172172}
173173
@@ -265,9 +265,9 @@ function prepareWebSocketForwarder (forwardToUrlPattern, entityIdPlaceholder) {
265265 /** @type {WebSocket } */ wsUpstream ,
266266 /** @type {import('http').IncomingMessage } */ req
267267 ) => {
268- this . logger . debug ( `Got a new websocket connection at ${ req . url } ` ) ;
268+ this . log . debug ( `Got a new websocket connection at ${ req . url } ` ) ;
269269 if ( ! req . url ) {
270- this . logger . debug ( 'The url is empty. Will ignore' ) ;
270+ this . log . debug ( 'The url is empty. Will ignore' ) ;
271271 wsUpstream . close ( WS_SERVER_POLICY_VIOLATION ) ;
272272 return ;
273273 }
@@ -276,7 +276,7 @@ function prepareWebSocketForwarder (forwardToUrlPattern, entityIdPlaceholder) {
276276 const dstUrl = entityId && forwardToUrlPattern . includes ( entityIdPlaceholder )
277277 ? forwardToUrlPattern . replace ( entityIdPlaceholder , entityId )
278278 : forwardToUrlPattern ;
279- this . logger . debug ( `Will forward upstream ${ req . url } to downstream ${ dstUrl } ` ) ;
279+ this . log . debug ( `Will forward upstream ${ req . url } to downstream ${ dstUrl } ` ) ;
280280 const wsDownstream = new WebSocket ( dstUrl ) ;
281281 wsDownstream . on ( 'message' , ( msg , binary ) => {
282282 if ( wsUpstream . readyState === WebSocket . OPEN ) {
@@ -289,13 +289,13 @@ function prepareWebSocketForwarder (forwardToUrlPattern, entityIdPlaceholder) {
289289 }
290290 } ) ;
291291 wsDownstream . once ( 'error' , ( e ) => {
292- this . logger . warn ( `Got an error from the downstream ${ dstUrl } : ${ e . message } ` ) ;
292+ this . log . warn ( `Got an error from the downstream ${ dstUrl } : ${ e . message } ` ) ;
293293 } ) ;
294294 wsUpstream . once ( 'error' , ( e ) => {
295- this . logger . info ( `Got an error from the upstream ${ req . url } : ${ e . message } ` ) ;
295+ this . log . info ( `Got an error from the upstream ${ req . url } : ${ e . message } ` ) ;
296296 } ) ;
297297 wsDownstream . once ( 'close' , ( code , reason ) => {
298- this . logger . info (
298+ this . log . info (
299299 `The downstream ${ dstUrl } has been closed: ${ code } , ` +
300300 `${ reason || '(no reason given)' } `
301301 ) ;
@@ -304,7 +304,7 @@ function prepareWebSocketForwarder (forwardToUrlPattern, entityIdPlaceholder) {
304304 }
305305 } ) ;
306306 wsUpstream . once ( 'close' , ( code , reason ) => {
307- this . logger . info (
307+ this . log . info (
308308 `The upstream ${ req . url } has been closed: ${ code } , ` +
309309 `${ reason || '(no reason given)' } `
310310 ) ;
@@ -332,7 +332,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
332332 throw new Error ( `The target '${ name } ' is already being proxied` ) ;
333333 }
334334
335- this . logger . debug ( `Starting the proxy for the Devtools target '${ name } '` ) ;
335+ this . log . debug ( `Starting the proxy for the Devtools target '${ name } '` ) ;
336336 let localPort = port ;
337337 if ( localPort ) {
338338 if ( await checkPortStatus ( localPort ) !== 'closed' ) {
@@ -345,7 +345,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
345345 const [ startPort , endPort ] = DEVTOOLS_BIND_PORTS_RANGE ;
346346 try {
347347 localPort = await findAPortNotInUse ( startPort , endPort ) ;
348- } catch ( e ) {
348+ } catch {
349349 throw new Error (
350350 `Cannot find any free port in range ${ startPort } ..${ endPort } ` +
351351 `to forward the Devtools socket '${ name } '. Try to provide a custom port ` +
@@ -358,7 +358,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
358358 try {
359359 await adb . removePortForward ( localPort ) ;
360360 } catch ( e ) {
361- this . logger . debug ( `Cannot remove the port forward. Original error: ${ e . message } ` ) ;
361+ this . log . debug ( `Cannot remove the port forward. Original error: ${ e . message } ` ) ;
362362 }
363363 } ;
364364 try {
@@ -378,7 +378,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
378378 }
379379 const browserDebuggerUrl = details . info [ DEBUGGER_URL_KEY ] ;
380380 if ( ! browserDebuggerUrl ) {
381- this . logger . debug ( JSON . stringify ( details . info ) ) ;
381+ this . log . debug ( JSON . stringify ( details . info ) ) ;
382382 await removePortForward ( ) ;
383383 throw new Error (
384384 `The target '${ name } ' cannot be proxied. ` +
@@ -400,7 +400,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
400400 let wdUrl ;
401401 try {
402402 wdUrl = new URL ( browserDebuggerUrl ) ;
403- } catch ( e ) {
403+ } catch {
404404 await removePortForward ( ) ;
405405 throw new Error (
406406 `The target '${ name } ' cannot be proxied. ` +
@@ -453,7 +453,7 @@ export async function proxyDevtoolsTarget (next, driver, name, port) {
453453 port : localPort ,
454454 rewrites,
455455 } ;
456- this . logger . info (
456+ this . log . info (
457457 `Successfully started the proxy for the Devtools target '${ name } ' at ${ forwardTo } : ` +
458458 JSON . stringify ( this . proxiedSessions [ alias ] , null , 2 )
459459 ) ;
@@ -474,7 +474,7 @@ export async function unproxyDevtoolsTarget (next, driver, name) {
474474 throw new Error ( `The target '${ name } ' is not being proxied` ) ;
475475 }
476476
477- this . logger . debug ( `Stopping the proxy for the Devtools target '${ name } '` ) ;
477+ this . log . debug ( `Stopping the proxy for the Devtools target '${ name } '` ) ;
478478 const {
479479 browserDebuggerPathname,
480480 pageDebuggerPathname,
@@ -489,10 +489,10 @@ export async function unproxyDevtoolsTarget (next, driver, name) {
489489 try {
490490 await step ( ) ;
491491 } catch ( e ) {
492- this . logger . warn ( e . message ) ;
492+ this . log . warn ( e . message ) ;
493493 }
494494 }
495- this . logger . info (
495+ this . log . info (
496496 `Successfully stopped the proxy for the Devtools target '${ name } ': ` +
497497 JSON . stringify ( this . proxiedSessions [ alias ] , null , 2 )
498498 ) ;
0 commit comments