fix: Private fields

This commit is contained in:
Felix Rieseberg 2024-10-07 12:49:49 -04:00
parent 9abc964e4f
commit 313cb13c91

View file

@ -73,7 +73,7 @@ class Logger {
}]
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.level = 'info'
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
}
#onLog (...args) {
_onLog (...args) {
const [level] = args
if (level === 'pause') {
@ -110,7 +110,7 @@ class Logger {
if (level === 'resume') {
this.#paused = false
this.#buffer.forEach((b) => this.#log(...b))
this.#buffer.forEach((b) => this._log(...b))
this.#buffer.length = 0
return
}
@ -120,10 +120,10 @@ class Logger {
return
}
this.#log(...args)
this._log(...args)
}
#color (str, { fg, bg, inverse }) {
_color (str, { fg, bg, inverse }) {
if (!this.#stream || !this.#stream.isTTY) {
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')) {
return
}
@ -143,11 +143,11 @@ class Logger {
const level = this.#levels.get(levelId)
const prefixParts = [
this.#color('gyp', { fg: 'white', bg: 'black' }),
this.#color(level.display || level.id, level.style)
this._color('gyp', { fg: 'white', bg: 'black' }),
this._color(level.display || level.id, level.style)
]
if (msgPrefix) {
prefixParts.push(this.#color(msgPrefix, { fg: 'magenta' }))
prefixParts.push(this._color(msgPrefix, { fg: 'magenta' }))
}
const prefix = prefixParts.join(' ').trim() + ' '