From 313cb13c9162c18e4d42d450522942edef41a89e Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Mon, 7 Oct 2024 12:49:49 -0400 Subject: [PATCH] fix: Private fields --- lib/log.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/log.js b/lib/log.js index 3f50230..1bac027 100644 --- a/lib/log.js +++ b/lib/log.js @@ -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() + ' '