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.
This commit is contained in:
Trent Mick 2015-09-07 01:21:43 -07:00
parent 6baeb2c581
commit 27d60578a9
3 changed files with 9 additions and 5 deletions

View file

@ -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)

View file

@ -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

View file

@ -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'});