Skip to content

Commit

Permalink
log errors as red in browser as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Nov 6, 2016
1 parent 440909f commit e4d400d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lighthouse-core/lib/log.js
Expand Up @@ -17,20 +17,27 @@
'use strict';

const debug = require('debug');
const debugNode = require('debug/node');
const EventEmitter = require('events').EventEmitter;

const isBrowser = process.browser;

const colors = {
red: 1,
yellow: 3,
cyan: 6,
green: 2,
blue: 4,
magenta: 5
red: isBrowser ? 'crimson' : 1,
yellow: isBrowser ? 'gold' : 3,
cyan: isBrowser ? 'darkturquoise' : 6,
green: isBrowser ? 'forestgreen' : 2,
blue: isBrowser ? 'steelblue' : 4,
magenta: isBrowser ? 'palevioletred' : 5
};

// whitelist non-red/yellow colors for debug()
debugNode.colors = [colors.cyan, colors.green, colors.blue, colors.magenta];
if (isBrowser) {
const debugBrowser = require('debug/browser');
debugBrowser.colors = [colors.cyan, colors.green, colors.blue, colors.magenta];
} else {
const debugNode = require('debug/node');
debugNode.colors = [colors.cyan, colors.green, colors.blue, colors.magenta];
}

class Emitter extends EventEmitter {
/**
Expand Down

0 comments on commit e4d400d

Please sign in to comment.