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