Better browser sniffing suggested at 414f33563d (commitcomment-7936060)

This commit is contained in:
Trent Mick 2014-09-26 20:46:27 -07:00
parent f5e5d577f0
commit 594cc82da1

View file

@ -47,13 +47,8 @@ try {
} }
// Are we in the browser (e.g. running via browserify)? // Are we in the browser (e.g. running via browserify)?
var browser; var isBrowser = function () {
try { return typeof (window) !== 'undefined' && this === window; }();
window
browser = true;
} catch (e) {
browser = false;
}
@ -380,7 +375,7 @@ function Logger(options, _childOptions, _childSimple) {
} else if (parent && options.level) { } else if (parent && options.level) {
this.level(options.level); this.level(options.level);
} else if (!parent) { } else if (!parent) {
if (browser) { if (isBrowser) {
/* /*
* In the browser we'll be emitting to console.log by default. * In the browser we'll be emitting to console.log by default.
* Any console.log worth its salt these days can nicely render * Any console.log worth its salt these days can nicely render