Skip to content

Commit

Permalink
feat(xen-api): use @xen-orchestra/log
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-f committed Jul 19, 2024
1 parent a0c3920 commit 0702454
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

- @xen-orchestra/vmware-explorer patch
- @xen-orchestra/xapi minor
- xen-api minor
- xo-server minor
- xo-web minor

Expand Down
3 changes: 0 additions & 3 deletions packages/xen-api/_debug.mjs

This file was deleted.

12 changes: 7 additions & 5 deletions packages/xen-api/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import Obfuscate from '@vates/obfuscate'
import { Agent, ProxyAgent, request } from 'undici'
import { coalesceCalls } from '@vates/coalesce-calls'
import { Collection } from 'xo-collection'
import { createLogger } from '@xen-orchestra/log'
import { EventEmitter } from 'events'
import { Index } from 'xo-collection/index.js'
import { cancelable, defer, fromCallback, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'
import { limitConcurrency } from 'limit-concurrency-decorator'
import { decorateClass } from '@vates/decorate-with'
import { ProxyAgent as HttpProxyAgent } from 'proxy-agent'

import debug from './_debug.mjs'
import getTaskResult from './_getTaskResult.mjs'
import isGetAllRecordsMethod from './_isGetAllRecordsMethod.mjs'
import isReadOnlyCall from './_isReadOnlyCall.mjs'
Expand All @@ -25,6 +25,8 @@ import parseUrl from './_parseUrl.mjs'
import Ref from './_Ref.mjs'
import transports from './transports/index.mjs'

const { debug } = createLogger('xen-api')

// ===================================================================

// in seconds!
Expand Down Expand Up @@ -255,7 +257,7 @@ export class Xapi extends EventEmitter {
try {
await this._sessionOpen()

debug('%s: connected', this._humanId)
debug(this._humanId + ': connected')
this._status = CONNECTED
this._resolveConnected()
this._resolveConnected = undefined
Expand Down Expand Up @@ -288,7 +290,7 @@ export class Xapi extends EventEmitter {
ignoreErrors.call(this._call('session.logout', [sessionId]))
}

debug('%s: disconnected', this._humanId)
debug(this._humanId + ': disconnected')

this._status = DISCONNECTED
this._resolveDisconnected()
Expand Down Expand Up @@ -777,7 +779,7 @@ export class Xapi extends EventEmitter {
const startTime = Date.now()
try {
const result = await pTimeout.call(this._addSyncStackTrace(this._transport(method, args)), timeout)
debug('%s: %s(...) [%s] ==> %s', this._humanId, method, ms(Date.now() - startTime), kindOf(result))
debug(`${this._humanId}: ${method}(...) [${ms(Date.now() - startTime)}] ==> ${kindOf(result)}`)
return result
} catch (error) {
// do not log the session ID
Expand All @@ -793,7 +795,7 @@ export class Xapi extends EventEmitter {
method === 'session.login_with_password' ? '* obfuscated *' : Obfuscate.replace(params, '* obfuscated *'),
}

debug('%s: %s(...) [%s] =!> %s', this._humanId, method, ms(Date.now() - startTime), error)
debug(`${this._humanId}: ${method} [${ms(Date.now() - startTime)}] =!> ${error}`)

throw error
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xen-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
"@vates/obfuscate": "^0.1.0",
"@vates/xml": "^2.0.0",
"@vates/xml-rpc": "^1.0.0",
"@xen-orchestra/log": "^0.6.0",
"bind-property-descriptor": "^2.0.0",
"blocked": "^1.2.1",
"debug": "^4.0.1",
"http-request-plus": "^1.0.2",
"jest-diff": "^29.0.3",
"json-rpc-protocol": "^0.13.1",
Expand Down
33 changes: 4 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9129,7 +9129,7 @@ [email protected], debug@^3.1.0, debug@^3.2.7:
dependencies:
ms "^2.1.1"

debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.0, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.4:
debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.0, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.4:
version "4.3.5"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e"
integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==
Expand Down Expand Up @@ -21430,7 +21430,7 @@ string-length@^6.0.0:
dependencies:
strip-ansi "^7.1.0"

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -21448,15 +21448,6 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^3.0.0, string-width@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
Expand Down Expand Up @@ -21573,7 +21564,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -21601,13 +21592,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -23796,7 +23780,7 @@ worker-farm@^1.7.0:
dependencies:
errno "~0.1.7"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down Expand Up @@ -23831,15 +23815,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 0702454

Please sign in to comment.