feat(providence): add perf logs to LogService
This commit is contained in:
parent
994a7b5266
commit
c7341d75ba
1 changed files with 16 additions and 1 deletions
|
|
@ -97,11 +97,25 @@ export class LogService {
|
||||||
log(colors.fgBlue, ` info${printTitle(title)}`, colors.reset, text);
|
log(colors.fgBlue, ` info${printTitle(title)}`, colors.reset, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {PerformanceMeasure} measurement
|
||||||
|
* @param {string} [title]
|
||||||
|
*/
|
||||||
|
static perf(measurement, title) {
|
||||||
|
const text = `${this.pad(`[${measurement.name}]`)} ${measurement.duration}ms`;
|
||||||
|
// @ts-ignore
|
||||||
|
this._logHistory.push(`- perf -${printTitle(title)} ${text}`);
|
||||||
|
if (this.allMuted || !this.perfEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log(colors.fgGray, ` perf${printTitle(title)}`, colors.reset, text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @param {number} minChars
|
* @param {number} minChars
|
||||||
*/
|
*/
|
||||||
static pad(text, minChars = 20) {
|
static pad(text, minChars = 40) {
|
||||||
let result = text;
|
let result = text;
|
||||||
const padding = minChars - text.length;
|
const padding = minChars - text.length;
|
||||||
if (padding > 0) {
|
if (padding > 0) {
|
||||||
|
|
@ -127,6 +141,7 @@ export class LogService {
|
||||||
LogService.debugEnabled = false;
|
LogService.debugEnabled = false;
|
||||||
LogService.allMuted = false;
|
LogService.allMuted = false;
|
||||||
LogService.throwsOnError = false;
|
LogService.throwsOnError = false;
|
||||||
|
LogService.perfEnabled = false;
|
||||||
|
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
LogService._logHistory = [];
|
LogService._logHistory = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue