@percy/logger
Advanced tools
Comparing version 1.0.0-beta.52 to 1.0.0-beta.53
@@ -25,4 +25,8 @@ "use strict"; | ||
progress() { | ||
console.error('The log.progress() method is not supported in browsers'); | ||
} | ||
} | ||
exports.default = BrowserLogger; |
@@ -145,2 +145,3 @@ (function() { | ||
}), { | ||
progress: this.progress.bind(this, name), | ||
deprecated: this.deprecated.bind(this, name), | ||
@@ -184,2 +185,22 @@ shouldLog: this.shouldLog.bind(this, name) | ||
return `[${label}] ${message}${suffix}`; | ||
} // Replaces the current line with a log message | ||
progress(debug, message, persist) { | ||
if (!this.shouldLog(debug, 'info')) return; | ||
let { | ||
stdout | ||
} = this.constructor; | ||
if (stdout.isTTY || !this._progress) { | ||
message && (message = this.format(message, debug)); | ||
if (stdout.isTTY) stdout.cursorTo(0);else message && (message = message + '\n'); | ||
if (message) stdout.write(message); | ||
if (stdout.isTTY) stdout.clearLine(1); | ||
} | ||
this._progress = !!message && { | ||
message, | ||
persist | ||
}; | ||
} // Returns true or false if the level and debug group can write messages to stdio | ||
@@ -250,4 +271,17 @@ | ||
write(level, message) { | ||
let stdio = level === 'info' ? 'stdout' : 'stderr'; | ||
this.constructor[stdio].write(message + '\n'); | ||
var _this$_progress; | ||
let { | ||
stdout, | ||
stderr | ||
} = this.constructor; | ||
let progress = stdout.isTTY && this._progress; | ||
if (progress) { | ||
stdout.cursorTo(0); | ||
stdout.clearLine(); | ||
} | ||
(level === 'info' ? stdout : stderr).write(message + '\n'); | ||
if (!((_this$_progress = this._progress) !== null && _this$_progress !== void 0 && _this$_progress.persist)) delete this._progress;else if (progress) stdout.write(progress.message); | ||
} // Opens a socket logging connection | ||
@@ -366,2 +400,6 @@ | ||
progress() { | ||
console.error('The log.progress() method is not supported in browsers'); | ||
} | ||
} | ||
@@ -368,0 +406,0 @@ |
@@ -90,2 +90,3 @@ "use strict"; | ||
}), { | ||
progress: this.progress.bind(this, name), | ||
deprecated: this.deprecated.bind(this, name), | ||
@@ -129,2 +130,22 @@ shouldLog: this.shouldLog.bind(this, name) | ||
return `[${label}] ${message}${suffix}`; | ||
} // Replaces the current line with a log message | ||
progress(debug, message, persist) { | ||
if (!this.shouldLog(debug, 'info')) return; | ||
let { | ||
stdout | ||
} = this.constructor; | ||
if (stdout.isTTY || !this._progress) { | ||
message && (message = this.format(message, debug)); | ||
if (stdout.isTTY) stdout.cursorTo(0);else message && (message = message + '\n'); | ||
if (message) stdout.write(message); | ||
if (stdout.isTTY) stdout.clearLine(1); | ||
} | ||
this._progress = !!message && { | ||
message, | ||
persist | ||
}; | ||
} // Returns true or false if the level and debug group can write messages to stdio | ||
@@ -195,4 +216,17 @@ | ||
write(level, message) { | ||
let stdio = level === 'info' ? 'stdout' : 'stderr'; | ||
this.constructor[stdio].write(message + '\n'); | ||
var _this$_progress; | ||
let { | ||
stdout, | ||
stderr | ||
} = this.constructor; | ||
let progress = stdout.isTTY && this._progress; | ||
if (progress) { | ||
stdout.cursorTo(0); | ||
stdout.clearLine(); | ||
} | ||
(level === 'info' ? stdout : stderr).write(message + '\n'); | ||
if (!((_this$_progress = this._progress) !== null && _this$_progress !== void 0 && _this$_progress.persist)) delete this._progress;else if (progress) stdout.write(progress.message); | ||
} // Opens a socket logging connection | ||
@@ -199,0 +233,0 @@ |
{ | ||
"name": "@percy/logger", | ||
"version": "1.0.0-beta.52", | ||
"version": "1.0.0-beta.53", | ||
"license": "MIT", | ||
@@ -29,3 +29,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "ebc543f148bede5ce057458ffb830dd60823837e" | ||
"gitHead": "42c93d11a663b5e45ab75944e20f0fb63a0dda09" | ||
} |
@@ -100,2 +100,8 @@ (function() { | ||
return Object.assign(new Writable(), { | ||
isTTY: options && options.isTTY, | ||
cursorTo() {}, | ||
clearLine() {}, | ||
_write(chunk, encoding, callback) { | ||
@@ -102,0 +108,0 @@ data.push(sanitizeLog(chunk.toString(), options)); |
@@ -25,2 +25,6 @@ const logger = require('@percy/logger'); | ||
return Object.assign(new Writable(), { | ||
isTTY: options && options.isTTY, | ||
cursorTo() {}, | ||
clearLine() {}, | ||
_write(chunk, encoding, callback) { | ||
@@ -27,0 +31,0 @@ data.push(sanitizeLog(chunk.toString(), options)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39160
958