From 27d60578a9844bd88d550100ce1595c6007b342a Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Mon, 7 Sep 2015 01:21:43 -0700 Subject: [PATCH] strict mode Should fix usage with bundles including bunyan and using strict mode. Had to fix a surprise effect that 'window === this' is no longer true in strict mode: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode """That means, among other things, that in browsers it's no longer possible to reference the window object through this inside a strict mode function.""" Fixes #236, #231, and #223. --- AUTHORS | 2 ++ CHANGES.md | 1 + lib/bunyan.js | 11 ++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 697ae75..6dbdd94 100644 --- a/AUTHORS +++ b/AUTHORS @@ -23,3 +23,5 @@ Martin Gausby (https://github.com/gausby) Stéphan Kochen (https://github.com/stephank) Shakeel Mohamed (https://github.com/shakeelmohamed) Denis Izmaylov (https://github.com/DenisIzmaylov) +Guillermo Grau Panea (https://github.com/guigrpa) +Mark LeMerise (https://github.com/MarkLeMerise) diff --git a/CHANGES.md b/CHANGES.md index a949ebf..19d96c3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ Known issues: ## bunyan 1.5.0 (not yet released) +- [pull #236, issue #231, issue #223] Fix strict mode in the browser. - [pull #282, issue #213] Fixes bunyan to work with webpack. By Denis Izmaylov. - [pull #294] Update to dtrace-provider 0.6 to fix with node 4.0 and io.js 3.0. - Dropped support for 0.8 (can't install deps easily anymore for running diff --git a/lib/bunyan.js b/lib/bunyan.js index c7eafe9..7016bfb 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -8,6 +8,8 @@ * vim: expandtab:ts=4:sw=4 */ +'use strict'; + var VERSION = '1.5.0'; // Bunyan log format version. This becomes the 'v' field on all log records. @@ -67,7 +69,7 @@ try { // Are we in the browser (e.g. running via browserify)? var isBrowser = function () { - return typeof (window) !== 'undefined' && this === window; }(); + return typeof (window) !== 'undefined'; }(); try { /* Use `+ ''` to hide this import from browserify. */ @@ -1095,12 +1097,11 @@ function safeCycles() { } -/** - * XXX - */ + +var RotatingFileStream = null; if (mv) { -function RotatingFileStream(options) { +RotatingFileStream = function RotatingFileStream(options) { this.path = options.path; this.stream = fs.createWriteStream(this.path, {flags: 'a', encoding: 'utf8'});