mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
fix: Private fields
This commit is contained in:
parent
9abc964e4f
commit
313cb13c91
1 changed files with 9 additions and 9 deletions
18
lib/log.js
18
lib/log.js
|
@ -73,7 +73,7 @@ class Logger {
|
||||||
}]
|
}]
|
||||||
|
|
||||||
constructor (stream) {
|
constructor (stream) {
|
||||||
process.on('log', (...args) => this.#onLog(...args))
|
process.on('log', (...args) => this._onLog(...args))
|
||||||
this.#levels = new Map(this.#levels.map((level, index) => [level.id, { ...level, index }]))
|
this.#levels = new Map(this.#levels.map((level, index) => [level.id, { ...level, index }]))
|
||||||
this.level = 'info'
|
this.level = 'info'
|
||||||
this.stream = stream
|
this.stream = stream
|
||||||
|
@ -100,7 +100,7 @@ class Logger {
|
||||||
return (this.level && this.level.index <= (this.#levels.get(level) && this.#levels.get(level).index)) || -1
|
return (this.level && this.level.index <= (this.#levels.get(level) && this.#levels.get(level).index)) || -1
|
||||||
}
|
}
|
||||||
|
|
||||||
#onLog (...args) {
|
_onLog (...args) {
|
||||||
const [level] = args
|
const [level] = args
|
||||||
|
|
||||||
if (level === 'pause') {
|
if (level === 'pause') {
|
||||||
|
@ -110,7 +110,7 @@ class Logger {
|
||||||
|
|
||||||
if (level === 'resume') {
|
if (level === 'resume') {
|
||||||
this.#paused = false
|
this.#paused = false
|
||||||
this.#buffer.forEach((b) => this.#log(...b))
|
this.#buffer.forEach((b) => this._log(...b))
|
||||||
this.#buffer.length = 0
|
this.#buffer.length = 0
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -120,10 +120,10 @@ class Logger {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#log(...args)
|
this._log(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
#color (str, { fg, bg, inverse }) {
|
_color (str, { fg, bg, inverse }) {
|
||||||
if (!this.#stream || !this.#stream.isTTY) {
|
if (!this.#stream || !this.#stream.isTTY) {
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class Logger {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
#log (levelId, msgPrefix, ...args) {
|
_log (levelId, msgPrefix, ...args) {
|
||||||
if (!this.isVisible(levelId) || (this.#stream && typeof this.#stream.write !== 'function')) {
|
if (!this.isVisible(levelId) || (this.#stream && typeof this.#stream.write !== 'function')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -143,11 +143,11 @@ class Logger {
|
||||||
const level = this.#levels.get(levelId)
|
const level = this.#levels.get(levelId)
|
||||||
|
|
||||||
const prefixParts = [
|
const prefixParts = [
|
||||||
this.#color('gyp', { fg: 'white', bg: 'black' }),
|
this._color('gyp', { fg: 'white', bg: 'black' }),
|
||||||
this.#color(level.display || level.id, level.style)
|
this._color(level.display || level.id, level.style)
|
||||||
]
|
]
|
||||||
if (msgPrefix) {
|
if (msgPrefix) {
|
||||||
prefixParts.push(this.#color(msgPrefix, { fg: 'magenta' }))
|
prefixParts.push(this._color(msgPrefix, { fg: 'magenta' }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const prefix = prefixParts.join(' ').trim() + ' '
|
const prefix = prefixParts.join(' ').trim() + ' '
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue