diff --git a/lib/core/diagnostics.js b/lib/core/diagnostics.js index 260721b44c5..44c168e6e79 100644 --- a/lib/core/diagnostics.js +++ b/lib/core/diagnostics.js @@ -36,57 +36,57 @@ function trackClientEvents (debugLog = undiciDebugLog) { isTrackingClientEvents = true - diagnosticsChannel.subscribe('undici:client:beforeConnect', + diagnosticsChannel.subscribe('undici:client:beforeConnect', evt => { - const { - connectParams: { version, protocol, port, host } - } = evt - debugLog( - 'connecting to %s%s using %s%s', - host, - port ? `:${port}` : '', - protocol, - version - ) - }) - - diagnosticsChannel.subscribe('undici:client:connected', + const { + connectParams: { version, protocol, port, host } + } = evt + debugLog( + 'connecting to %s%s using %s%s', + host, + port ? `:${port}` : '', + protocol, + version + ) + }) + + diagnosticsChannel.subscribe('undici:client:connected', evt => { - const { - connectParams: { version, protocol, port, host } - } = evt - debugLog( - 'connected to %s%s using %s%s', - host, - port ? `:${port}` : '', - protocol, - version - ) - }) - - diagnosticsChannel.subscribe('undici:client:connectError', + const { + connectParams: { version, protocol, port, host } + } = evt + debugLog( + 'connected to %s%s using %s%s', + host, + port ? `:${port}` : '', + protocol, + version + ) + }) + + diagnosticsChannel.subscribe('undici:client:connectError', evt => { - const { - connectParams: { version, protocol, port, host }, - error - } = evt - debugLog( - 'connection to %s%s using %s%s errored - %s', - host, - port ? `:${port}` : '', - protocol, - version, - error.message - ) - }) - - diagnosticsChannel.subscribe('undici:client:sendHeaders', + const { + connectParams: { version, protocol, port, host }, + error + } = evt + debugLog( + 'connection to %s%s using %s%s errored - %s', + host, + port ? `:${port}` : '', + protocol, + version, + error.message + ) + }) + + diagnosticsChannel.subscribe('undici:client:sendHeaders', evt => { - const { - request: { method, path, origin } - } = evt - debugLog('sending request to %s %s/%s', method, origin, path) - }) + const { + request: { method, path, origin } + } = evt + debugLog('sending request to %s %s/%s', method, origin, path) + }) } let isTrackingRequestEvents = false @@ -98,43 +98,43 @@ function trackRequestEvents (debugLog = undiciDebugLog) { isTrackingRequestEvents = true - diagnosticsChannel.subscribe('undici:request:headers', + diagnosticsChannel.subscribe('undici:request:headers', evt => { - const { - request: { method, path, origin }, - response: { statusCode } - } = evt - debugLog( - 'received response to %s %s/%s - HTTP %d', - method, - origin, - path, - statusCode - ) - }) - - diagnosticsChannel.subscribe('undici:request:trailers', + const { + request: { method, path, origin }, + response: { statusCode } + } = evt + debugLog( + 'received response to %s %s/%s - HTTP %d', + method, + origin, + path, + statusCode + ) + }) + + diagnosticsChannel.subscribe('undici:request:trailers', evt => { - const { - request: { method, path, origin } - } = evt - debugLog('trailers received from %s %s/%s', method, origin, path) - }) + const { + request: { method, path, origin } + } = evt + debugLog('trailers received from %s %s/%s', method, origin, path) + }) - diagnosticsChannel.subscribe('undici:request:error', + diagnosticsChannel.subscribe('undici:request:error', evt => { - const { - request: { method, path, origin }, - error - } = evt - debugLog( - 'request to %s %s/%s errored - %s', - method, - origin, - path, - error.message - ) - }) + const { + request: { method, path, origin }, + error + } = evt + debugLog( + 'request to %s %s/%s errored - %s', + method, + origin, + path, + error.message + ) + }) } let isTrackingWebSocketEvents = false @@ -146,39 +146,39 @@ function trackWebSocketEvents (debugLog = websocketDebuglog) { isTrackingWebSocketEvents = true - diagnosticsChannel.subscribe('undici:websocket:open', + diagnosticsChannel.subscribe('undici:websocket:open', evt => { - const { - address: { address, port } - } = evt - debugLog('connection opened %s%s', address, port ? `:${port}` : '') - }) + const { + address: { address, port } + } = evt + debugLog('connection opened %s%s', address, port ? `:${port}` : '') + }) - diagnosticsChannel.subscribe('undici:websocket:close', + diagnosticsChannel.subscribe('undici:websocket:close', evt => { - const { websocket, code, reason } = evt - debugLog( - 'closed connection to %s - %s %s', - websocket.url, - code, - reason - ) - }) - - diagnosticsChannel.subscribe('undici:websocket:socket_error', + const { websocket, code, reason } = evt + debugLog( + 'closed connection to %s - %s %s', + websocket.url, + code, + reason + ) + }) + + diagnosticsChannel.subscribe('undici:websocket:socket_error', err => { - debugLog('connection errored - %s', err.message) - }) + debugLog('connection errored - %s', err.message) + }) - diagnosticsChannel.subscribe('undici:websocket:ping', + diagnosticsChannel.subscribe('undici:websocket:ping', evt => { - debugLog('ping received') - }) + debugLog('ping received') + }) - diagnosticsChannel.subscribe('undici:websocket:pong', + diagnosticsChannel.subscribe('undici:websocket:pong', evt => { - debugLog('pong received') - }) + debugLog('pong received') + }) } if (undiciDebugLog.enabled || fetchDebuglog.enabled) {