playwright-performance-reporter
Version:
Measure and publish performance metrics from browser dev-tools when running playwright
48 lines (47 loc) • 1.21 kB
JavaScript
export class Logger {
/**
* Dispatch log as info
*
* @param message main message
* @param args meta data
*/
static info(message, ...arguments_) {
console.log(this.prefix, this.getDate(), this.logLevels.info, message, arguments_.join(', '));
}
/**
* Dispatch log as warning
*
* @param message main message
* @param args meta data
*/
static warning(message, ...arguments_) {
console.log(this.prefix, this.getDate(), this.logLevels.warning, message, arguments_.join(', '));
}
/**
* Dispatch log as error
*
* @param message main message
* @param args meta data
*/
static error(message, ...arguments_) {
console.log(this.prefix, this.getDate(), this.logLevels.error, message, arguments_.join(', '));
}
/**
* General prefix for every log
*/
static prefix = '[PerformanceLogger]';
/**
* Supported log levels
*/
static logLevels = {
info: '[info]',
warning: '[warning]',
error: '[error]',
};
/**
* Returns date for logging
*/
static getDate() {
return `[${(new Date()).toISOString()}]`;
}
}