Skip to content

Commit

Permalink
misc(logger): isVerbose(), getTimeEntries() (#6383)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored and paulirish committed Oct 24, 2018
1 parent e3949e2 commit 55b96b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion lighthouse-logger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Emitter extends EventEmitter {

const loggersByTitle = {};
const loggingBufferColumns = 25;
let level_;

class Log {
static _logToStdErr(title, argsArray) {
Expand All @@ -74,7 +75,11 @@ class Log {
return log;
}

/**
* @param {string} level
*/
static setLevel(level) {
level_ = level;
switch (level) {
case 'silent':
debug.enable('-*');
Expand Down Expand Up @@ -106,6 +111,13 @@ class Log {
Log._logToStdErr(`${prefix}:${level || ''}`, [method, snippet]);
}

/**
* @return {boolean}
*/
static isVerbose() {
return level_ === 'verbose';
}

static time({msg, id, args = []}, level = 'log') {
marky.mark(id);
Log[level]('status', msg, ...args);
Expand Down Expand Up @@ -219,10 +231,11 @@ class Log {
}

Log.events = new Emitter();
Log.takeTimeEntries = _ => {
Log.takeTimeEntries = () => {
const entries = marky.getEntries();
marky.clear();
return entries;
};
Log.getTimeEntries = () => marky.getEntries();

module.exports = Log;
2 changes: 1 addition & 1 deletion lighthouse-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lighthouse-logger",
"version": "1.1.0",
"version": "1.2.0",
"license": "Apache-2.0",
"dependencies": {
"debug": "^2.6.8",
Expand Down

0 comments on commit 55b96b2

Please sign in to comment.