passenger 6.0.12 → 6.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +37 -1
  3. data/bin/passenger-install-nginx-module +1 -1
  4. data/dev/copy_boost_headers +30 -15
  5. data/resources/mime.types +1 -0
  6. data/resources/templates/standalone/server.erb +1 -0
  7. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +1 -0
  8. data/src/agent/Core/ApplicationPool/Options.h +5 -0
  9. data/src/agent/Core/Config.h +1 -1
  10. data/src/agent/Core/Controller/Config.h +5 -2
  11. data/src/agent/Core/Controller/InitRequest.cpp +2 -0
  12. data/src/agent/Core/OptionParser.h +4 -0
  13. data/src/agent/Core/SpawningKit/Config/AutoGeneratedCode.h +7 -0
  14. data/src/agent/Core/SpawningKit/Config.h +13 -0
  15. data/src/agent/Core/SpawningKit/Handshake/Prepare.h +4 -0
  16. data/src/agent/Core/SpawningKit/Spawner.h +1 -0
  17. data/src/agent/SpawnEnvSetupper/SpawnEnvSetupperMain.cpp +4 -0
  18. data/src/agent/Watchdog/Config.h +1 -1
  19. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +5 -0
  20. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  21. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +18 -0
  22. data/src/apache2_module/DirConfig/AutoGeneratedCreateFunction.cpp +3 -0
  23. data/src/apache2_module/DirConfig/AutoGeneratedHeaderSerialization.cpp +3 -0
  24. data/src/apache2_module/DirConfig/AutoGeneratedManifestGeneration.cpp +11 -0
  25. data/src/apache2_module/DirConfig/AutoGeneratedMergeFunction.cpp +7 -0
  26. data/src/apache2_module/DirConfig/AutoGeneratedStruct.h +17 -0
  27. data/src/apache2_module/Hooks.cpp +1 -0
  28. data/src/cxx_supportlib/Constants.h +1 -1
  29. data/src/cxx_supportlib/vendor-modified/boost/align/align.hpp +19 -0
  30. data/src/cxx_supportlib/vendor-modified/boost/align/alignment_of.hpp +54 -0
  31. data/src/cxx_supportlib/vendor-modified/boost/align/alignment_of_forward.hpp +20 -0
  32. data/src/cxx_supportlib/vendor-modified/boost/align/detail/align_cxx11.hpp +21 -0
  33. data/src/cxx_supportlib/vendor-modified/boost/align/detail/aligned_alloc.hpp +52 -0
  34. data/src/cxx_supportlib/vendor-modified/boost/align/detail/alignment_of.hpp +31 -0
  35. data/src/cxx_supportlib/vendor-modified/boost/align/detail/alignment_of_cxx11.hpp +23 -0
  36. data/src/cxx_supportlib/vendor-modified/boost/align/detail/element_type.hpp +91 -0
  37. data/src/cxx_supportlib/vendor-modified/boost/align/detail/integral_constant.hpp +53 -0
  38. data/src/cxx_supportlib/vendor-modified/boost/align/detail/min_size.hpp +26 -0
  39. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +8 -0
  40. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +6 -0
  41. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +12 -0
  42. data/src/nginx_module/LocationConfig/AutoGeneratedCreateFunction.c +5 -0
  43. data/src/nginx_module/LocationConfig/AutoGeneratedHeaderSerialization.c +18 -0
  44. data/src/nginx_module/LocationConfig/AutoGeneratedManifestGeneration.c +13 -0
  45. data/src/nginx_module/LocationConfig/AutoGeneratedMergeFunction.c +3 -0
  46. data/src/nginx_module/LocationConfig/AutoGeneratedStruct.h +4 -0
  47. data/src/nginx_module/ngx_http_passenger_module.c +1 -0
  48. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/common.js +50 -29
  49. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/cli-config.js +20 -20
  50. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/npm-config.js +11 -11
  51. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config/syslog-config.js +3 -3
  52. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/config.js +8 -2
  53. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/container.js +2 -1
  54. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/logger.js +174 -146
  55. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/console.js +4 -2
  56. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/file.js +15 -5
  57. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/http.js +14 -4
  58. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports.js +26 -24
  59. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston.js +5 -5
  60. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/async/package.json +4 -13
  61. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/colors/package.json +19 -33
  62. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/cycle/package.json +11 -29
  63. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/eyes/package.json +12 -40
  64. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/isstream/package.json +3 -12
  65. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/lib/stack-trace.js +49 -24
  66. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/stack-trace/package.json +4 -16
  67. data/src/nodejs_supportlib/vendor-copy/winston/package.json +11 -55
  68. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +6 -0
  69. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +6 -0
  70. data/src/ruby_supportlib/phusion_passenger/platform_info/linux.rb +2 -1
  71. data/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb +18 -18
  72. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +7 -1
  73. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +1 -0
  74. data/src/ruby_supportlib/phusion_passenger.rb +5 -5
  75. metadata +12 -7
  76. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/daily-rotate-file.js +0 -601
  77. data/src/nodejs_supportlib/vendor-copy/winston/lib/winston/transports/webhook.js +0 -146
  78. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/LICENSE +0 -19
  79. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/lib/pkginfo.js +0 -136
  80. data/src/nodejs_supportlib/vendor-copy/winston/node_modules/pkginfo/package.json +0 -56
@@ -14,6 +14,8 @@ var events = require('events'),
14
14
  exception = require('./exception'),
15
15
  Stream = require('stream').Stream;
16
16
 
17
+ var formatRegExp = /%[sdj%]/g;
18
+
17
19
  //
18
20
  // ### function Logger (options)
19
21
  // #### @options {Object} Options for this instance.
@@ -22,10 +24,41 @@ var events = require('events'),
22
24
  //
23
25
  var Logger = exports.Logger = function (options) {
24
26
  events.EventEmitter.call(this);
27
+ this.configure(options);
28
+ };
29
+
30
+ //
31
+ // Inherit from `events.EventEmitter`.
32
+ //
33
+ util.inherits(Logger, events.EventEmitter);
34
+
35
+ //
36
+ // ### function configure (options)
37
+ // This will wholesale reconfigure this instance by:
38
+ // 1. Resetting all transports. Older transports will be removed implicitly.
39
+ // 2. Set all other options including levels, colors, rewriters, filters,
40
+ // exceptionHandlers, etc.
41
+ //
42
+ Logger.prototype.configure = function (options) {
43
+ var self = this;
44
+
45
+ //
46
+ // If we have already been setup with transports
47
+ // then remove them before proceeding.
48
+ //
49
+ if (Array.isArray(this._names) && this._names.length) {
50
+ this.clear();
51
+ }
52
+
25
53
  options = options || {};
54
+ this.transports = {};
55
+ this._names = [];
26
56
 
27
- var self = this,
28
- handleExceptions = false;
57
+ if (options.transports) {
58
+ options.transports.forEach(function (transport) {
59
+ self.add(transport, null, true);
60
+ });
61
+ }
29
62
 
30
63
  //
31
64
  // Set Levels and default logging level
@@ -39,6 +72,7 @@ var Logger = exports.Logger = function (options) {
39
72
  //
40
73
  // Hoist other options onto this instance.
41
74
  //
75
+ this.id = options.id || null;
42
76
  this.level = options.level || 'info';
43
77
  this.emitErrs = options.emitErrs || false;
44
78
  this.stripColors = options.stripColors || false;
@@ -47,65 +81,21 @@ var Logger = exports.Logger = function (options) {
47
81
  : true;
48
82
 
49
83
  //
50
- // Setup other intelligent default settings.
84
+ // Setup internal state as empty Objects even though it is
85
+ // defined lazily later to ensure a strong existential API contract.
51
86
  //
52
- this.transports = {};
53
- this.rewriters = [];
54
- this.filters = [];
55
87
  this.exceptionHandlers = {};
56
88
  this.profilers = {};
57
- this._names = [];
58
- this._hnames = [];
59
-
60
- if (options.transports) {
61
- options.transports.forEach(function (transport) {
62
- self.add(transport, null, true);
63
89
 
64
- if (transport.handleExceptions) {
65
- handleExceptions = true;
66
- }
67
- });
68
- }
69
-
70
- if (options.rewriters) {
71
- options.rewriters.forEach(function (rewriter) {
72
- self.addRewriter(rewriter);
73
- });
74
- }
90
+ ['rewriters', 'filters'].forEach(function (kind) {
91
+ self[kind] = Array.isArray(options[kind])
92
+ ? options[kind]
93
+ : [];
94
+ });
75
95
 
76
96
  if (options.exceptionHandlers) {
77
- handleExceptions = true;
78
- options.exceptionHandlers.forEach(function (handler) {
79
- self._hnames.push(handler.name);
80
- self.exceptionHandlers[handler.name] = handler;
81
- });
97
+ this.handleExceptions(options.exceptionHandlers);
82
98
  }
83
-
84
- if (options.handleExceptions || handleExceptions) {
85
- this.handleExceptions();
86
- }
87
- };
88
-
89
- //
90
- // Inherit from `events.EventEmitter`.
91
- //
92
- util.inherits(Logger, events.EventEmitter);
93
-
94
- //
95
- // ### function extend (target)
96
- // #### @target {Object} Target to extend.
97
- // Extends the target object with a 'log' method
98
- // along with a method for each level in this instance.
99
- //
100
- Logger.prototype.extend = function (target) {
101
- var self = this;
102
- ['log', 'profile', 'startTimer'].concat(Object.keys(this.levels)).forEach(function (method) {
103
- target[method] = function () {
104
- return self[method].apply(self, arguments);
105
- };
106
- });
107
-
108
- return this;
109
99
  };
110
100
 
111
101
  //
@@ -117,23 +107,28 @@ Logger.prototype.extend = function (target) {
117
107
  // Core logging method exposed to Winston. Metadata is optional.
118
108
  //
119
109
  Logger.prototype.log = function (level) {
120
- var self = this,
121
- args = Array.prototype.slice.call(arguments, 1);
110
+ var args = Array.prototype.slice.call(arguments, 1),
111
+ self = this,
112
+ transports;
122
113
 
123
- while(args[args.length - 1] === null) {
114
+ while (args[args.length - 1] === null) {
124
115
  args.pop();
125
116
  }
126
117
 
127
- var callback = typeof args[args.length - 1] === 'function' ? args.pop() : null,
128
- meta = typeof args[args.length - 1] === 'object' && Object.prototype.toString.call(args[args.length - 1]) !== '[object RegExp]' ? args.pop() : {},
129
- msg = util.format.apply(null, args);
130
-
131
- // If we should pad for levels, do so
132
- if (this.padLevels) {
133
- msg = new Array(this.levelLength - level.length + 1).join(' ') + msg;
134
- }
118
+ //
119
+ // Determining what is `meta` and what are arguments for string interpolation
120
+ // turns out to be VERY tricky. e.g. in the cases like this:
121
+ //
122
+ // logger.info('No interpolation symbols', 'ok', 'why', { meta: 'is-this' });
123
+ //
124
+ var callback = typeof args[args.length - 1] === 'function'
125
+ ? args.pop()
126
+ : null;
135
127
 
136
- function onError (err) {
128
+ //
129
+ // Handle errors appropriately.
130
+ //
131
+ function onError(err) {
137
132
  if (callback) {
138
133
  callback(err);
139
134
  }
@@ -142,20 +137,75 @@ Logger.prototype.log = function (level) {
142
137
  }
143
138
  }
144
139
 
145
-
146
- if (Object.keys(this.transports).length === 0) {
140
+ if (this._names.length === 0) {
147
141
  return onError(new Error('Cannot log with no transports.'));
148
142
  }
149
143
  else if (typeof self.levels[level] === 'undefined') {
150
144
  return onError(new Error('Unknown log level: ' + level));
151
145
  }
152
146
 
147
+ //
148
+ // If there are no transports that match the level
149
+ // then be eager and return. This could potentially be calculated
150
+ // during `setLevels` for more performance gains.
151
+ //
152
+ var targets = this._names.filter(function (name) {
153
+ var transport = self.transports[name];
154
+ return (transport.level && self.levels[transport.level] >= self.levels[level])
155
+ || (!transport.level && self.levels[self.level] >= self.levels[level]);
156
+ });
157
+
158
+ if (!targets.length) {
159
+ if (callback) { callback(); }
160
+ return;
161
+ }
162
+
163
+ //
164
+ // Determining what is `meta` and what are arguments for string interpolation
165
+ // turns out to be VERY tricky. e.g. in the cases like this:
166
+ //
167
+ // logger.info('No interpolation symbols', 'ok', 'why', { meta: 'is-this' });
168
+ //
169
+ var msg, meta = {}, validMeta = false;
170
+ var hasFormat = args && args[0] && args[0].match && args[0].match(formatRegExp) !== null;
171
+ var tokens = (hasFormat) ? args[0].match(formatRegExp) : [];
172
+ var ptokens = tokens.filter(function(t) { return t === '%%' });
173
+ if (((args.length - 1) - (tokens.length - ptokens.length)) > 0 || args.length === 1) {
174
+ // last arg is meta
175
+ meta = args[args.length - 1] || args;
176
+ var metaType = Object.prototype.toString.call(meta);
177
+ validMeta = metaType === '[object Object]' ||
178
+ metaType === '[object Error]' || metaType === '[object Array]';
179
+ meta = validMeta ? args.pop() : {};
180
+ }
181
+ msg = util.format.apply(null, args);
182
+
183
+ //
184
+ // Respond to the callback.
185
+ //
186
+ function finish(err) {
187
+ if (callback) {
188
+ if (err) return callback(err);
189
+ callback(null, level, msg, meta);
190
+ }
191
+
192
+ callback = null;
193
+ if (!err) {
194
+ self.emit('logged', level, msg, meta);
195
+ }
196
+ }
197
+
198
+ // If we should pad for levels, do so
199
+ if (this.padLevels) {
200
+ msg = new Array(this.levelLength - level.length + 1).join(' ') + msg;
201
+ }
202
+
153
203
  this.rewriters.forEach(function (rewriter) {
154
204
  meta = rewriter(level, msg, meta, self);
155
205
  });
156
206
 
157
207
  this.filters.forEach(function(filter) {
158
- var filtered = filter(msg, meta, level, self);
208
+ var filtered = filter(level, msg, meta, self);
159
209
  if (typeof filtered === 'string')
160
210
  msg = filtered;
161
211
  else {
@@ -179,40 +229,21 @@ Logger.prototype.log = function (level) {
179
229
  //
180
230
  // Log for each transport and emit 'logging' event
181
231
  //
182
- function emit(name, next) {
232
+ function transportLog(name, next) {
183
233
  var transport = self.transports[name];
184
- if ((transport.level && self.levels[transport.level] <= self.levels[level])
185
- || (!transport.level && self.levels[self.level] <= self.levels[level])) {
186
- transport.log(level, msg, meta, function (err) {
187
- if (err) {
188
- err.transport = transport;
189
- cb(err);
190
- return next();
191
- }
192
- self.emit('logging', transport, level, msg, meta);
193
- next();
194
- });
195
- } else {
196
- next();
197
- }
198
- }
234
+ transport.log(level, msg, meta, function (err) {
235
+ if (err) {
236
+ err.transport = transport;
237
+ finish(err);
238
+ return next();
239
+ }
199
240
 
200
- //
201
- // Respond to the callback
202
- //
203
- function cb(err) {
204
- if (callback) {
205
- if (err) return callback(err);
206
- callback(null, level, msg, meta);
207
- }
208
- callback = null;
209
- if (!err) {
210
- self.emit('logged', level, msg, meta);
211
- }
241
+ self.emit('logging', transport, level, msg, meta);
242
+ next();
243
+ });
212
244
  }
213
245
 
214
- async.forEach(this._names, emit, cb);
215
-
246
+ async.forEach(targets, transportLog, finish);
216
247
  return this;
217
248
  };
218
249
 
@@ -257,7 +288,7 @@ Logger.prototype.query = function (options, callback) {
257
288
  // Helper function to accumulate the results from
258
289
  // `queryTransport` into the `results`.
259
290
  //
260
- function addResults (transport, next) {
291
+ function addResults(transport, next) {
261
292
  queryTransport(transport, function (err, result) {
262
293
  //
263
294
  // queryTransport could potentially invoke the callback
@@ -379,8 +410,9 @@ Logger.prototype.close = function () {
379
410
  };
380
411
 
381
412
  //
382
- // ### function handleExceptions ()
383
- // Handles `uncaughtException` events for the current process
413
+ // ### function handleExceptions ([tr0, tr1...] || tr0, tr1, ...)
414
+ // Handles `uncaughtException` events for the current process by
415
+ // ADDING any handlers passed in.
384
416
  //
385
417
  Logger.prototype.handleExceptions = function () {
386
418
  var args = Array.prototype.slice.call(arguments),
@@ -396,6 +428,7 @@ Logger.prototype.handleExceptions = function () {
396
428
  }
397
429
  });
398
430
 
431
+ this.exceptionHandlers = this.exceptionHandlers || {};
399
432
  handlers.forEach(function (handler) {
400
433
  self.exceptionHandlers[handler.name] = handler;
401
434
  });
@@ -451,7 +484,7 @@ Logger.prototype.add = function (transport, options, created) {
451
484
  throw new Error('Unknown transport with no log() method');
452
485
  }
453
486
  else if (this.transports[instance.name]) {
454
- throw new Error('Transport already attached: ' + instance.name);
487
+ throw new Error('Transport already attached: ' + instance.name + ", assign a different name");
455
488
  }
456
489
 
457
490
  this.transports[instance.name] = instance;
@@ -476,37 +509,14 @@ Logger.prototype.add = function (transport, options, created) {
476
509
  return this;
477
510
  };
478
511
 
479
- //
480
- // ### function addRewriter (transport, [options])
481
- // #### @transport {Transport} Prototype of the Transport object to add.
482
- // #### @options {Object} **Optional** Options for the Transport to add.
483
- // #### @instance {Boolean} **Optional** Value indicating if `transport` is already instantiated.
484
- // Adds a transport of the specified type to this instance.
485
- //
486
- Logger.prototype.addRewriter = function (rewriter) {
487
- this.rewriters.push(rewriter);
488
- }
489
-
490
- //
491
- // ### function addFilter (filter)
492
- // #### @filter {function} Filter function, called with the message and
493
- // optional metadata as the two arguments.
494
- // Expected to return either the filtered message or an object with properties:
495
- // - msg = the filtered message string
496
- // - meta = the filtered metadata object
497
- //
498
- Logger.prototype.addFilter = function (filter) {
499
- this.filters.push(filter);
500
- }
501
-
502
512
  //
503
513
  // ### function clear ()
504
514
  // Remove all transports from this instance
505
515
  //
506
516
  Logger.prototype.clear = function () {
507
- for (var name in this.transports) {
517
+ Object.keys(this.transports).forEach(function (name) {
508
518
  this.remove({ name: name });
509
- }
519
+ }, this);
510
520
  };
511
521
 
512
522
  //
@@ -537,26 +547,19 @@ Logger.prototype.remove = function (transport) {
537
547
  return this;
538
548
  };
539
549
 
540
- var ProfileHandler = function (logger) {
541
- this.logger = logger;
542
-
543
- this.start = Date.now();
544
-
545
- this.done = function (msg) {
546
- var args, callback, meta;
547
- args = Array.prototype.slice.call(arguments);
548
- callback = typeof args[args.length - 1] === 'function' ? args.pop() : null;
549
- meta = typeof args[args.length - 1] === 'object' ? args.pop() : {};
550
-
551
- meta.durationMs = (Date.now()) - this.start;
552
-
553
- return this.logger.info(msg, meta, callback);
554
- }
555
- }
556
-
550
+ //
551
+ // ### function startTimer ()
552
+ // Returns an object corresponding to a specific timing. When done
553
+ // is called the timer will finish and log the duration. e.g.:
554
+ //
555
+ // timer = winston.startTimer()
556
+ // setTimeout(function(){
557
+ // timer.done("Logging message");
558
+ // }, 1000);
559
+ //
557
560
  Logger.prototype.startTimer = function () {
558
561
  return new ProfileHandler(this);
559
- }
562
+ };
560
563
 
561
564
  //
562
565
  // ### function profile (id, [msg, meta, callback])
@@ -699,3 +702,28 @@ Logger.prototype._onError = function (transport, err) {
699
702
  this.emit('error', err, transport);
700
703
  }
701
704
  };
705
+
706
+ //
707
+ // ### @private ProfileHandler
708
+ // Constructor function for the ProfileHandler instance used by
709
+ // `Logger.prototype.startTimer`. When done is called the timer
710
+ // will finish and log the duration.
711
+ //
712
+ function ProfileHandler(logger) {
713
+ this.logger = logger;
714
+ this.start = Date.now();
715
+ }
716
+
717
+ //
718
+ // ### function done (msg)
719
+ // Ends the current timer (i.e. ProfileHandler) instance and
720
+ // logs the `msg` along with the duration since creation.
721
+ //
722
+ ProfileHandler.prototype.done = function (msg) {
723
+ var args = Array.prototype.slice.call(arguments),
724
+ callback = typeof args[args.length - 1] === 'function' ? args.pop() : null,
725
+ meta = typeof args[args.length - 1] === 'object' ? args.pop() : {};
726
+
727
+ meta.duration = (Date.now()) - this.start + 'ms';
728
+ return this.logger.info(msg, meta, callback);
729
+ };
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  var events = require('events'),
10
+ os = require('os'),
10
11
  util = require('util'),
11
12
  common = require('../common'),
12
13
  Transport = require('./transport').Transport;
@@ -31,6 +32,7 @@ var Console = exports.Console = function (options) {
31
32
  this.depth = options.depth || null;
32
33
  this.align = options.align || false;
33
34
  this.stderrLevels = setStderrLevels(options.stderrLevels, options.debugStdout);
35
+ this.eol = options.eol || os.EOL;
34
36
 
35
37
  if (this.json) {
36
38
  this.stringify = options.stringify || function (obj) {
@@ -114,9 +116,9 @@ Console.prototype.log = function (level, msg, meta, callback) {
114
116
  });
115
117
 
116
118
  if (this.stderrLevels[level]) {
117
- process.stderr.write(output + '\n');
119
+ process.stderr.write(output + this.eol);
118
120
  } else {
119
- process.stdout.write(output + '\n');
121
+ process.stdout.write(output + this.eol);
120
122
  }
121
123
 
122
124
  //
@@ -159,8 +159,11 @@ File.prototype.log = function (level, msg, meta, callback) {
159
159
  depth: this.depth,
160
160
  formatter: this.formatter,
161
161
  humanReadableUnhandledException: this.humanReadableUnhandledException
162
- }) + this.eol;
162
+ });
163
163
 
164
+ if (typeof output === 'string') {
165
+ output += this.eol;
166
+ }
164
167
 
165
168
  if (!this.filename) {
166
169
  //
@@ -284,7 +287,8 @@ File.prototype.query = function (options, callback) {
284
287
  }
285
288
 
286
289
  function push(log) {
287
- if (options.rows && results.length >= options.rows) {
290
+ if (options.rows && results.length >= options.rows
291
+ && options.order != 'desc') {
288
292
  if (stream.readable) {
289
293
  stream.destroy();
290
294
  }
@@ -299,6 +303,11 @@ File.prototype.query = function (options, callback) {
299
303
  log = obj;
300
304
  }
301
305
 
306
+ if (options.order === 'desc') {
307
+ if (results.length >= options.rows) {
308
+ results.shift();
309
+ }
310
+ }
302
311
  results.push(log);
303
312
  }
304
313
 
@@ -309,7 +318,8 @@ File.prototype.query = function (options, callback) {
309
318
 
310
319
  var time = new Date(log.timestamp);
311
320
  if ((options.from && time < options.from)
312
- || (options.until && time > options.until)) {
321
+ || (options.until && time > options.until)
322
+ || (options.level && options.level !== log.level)) {
313
323
  return;
314
324
  }
315
325
 
@@ -521,7 +531,7 @@ File.prototype._createStream = function () {
521
531
 
522
532
  inp.pipe(gzip).pipe(out);
523
533
 
524
- fs.unlink(String(self._archive));
534
+ fs.unlink(String(self._archive), function () {});
525
535
  self._archive = '';
526
536
  }
527
537
  }
@@ -668,7 +678,7 @@ File.prototype._lazyDrain = function () {
668
678
  this._draining = true;
669
679
 
670
680
  this._stream.once('drain', function () {
671
- this._draining = false;
681
+ self._draining = false;
672
682
  self.emit('logged');
673
683
  });
674
684
  }
@@ -21,6 +21,9 @@ var Http = exports.Http = function (options) {
21
21
  this.port = options.port;
22
22
  this.auth = options.auth;
23
23
  this.path = options.path || '';
24
+ this.agent = options.agent;
25
+ this.headers = options.headers || {};
26
+ this.headers['content-type'] = 'application/json';
24
27
 
25
28
  if (!this.port) {
26
29
  this.port = this.ssl ? 443 : 80;
@@ -56,20 +59,27 @@ Http.prototype._request = function (options, callback) {
56
59
  port: this.port,
57
60
  path: '/' + path.replace(/^\//, ''),
58
61
  method: 'POST',
59
- headers: { 'Content-Type': 'application/json' },
62
+ headers: this.headers,
63
+ agent: this.agent,
60
64
  auth: (auth) ? auth.username + ':' + auth.password : ''
61
65
  });
62
66
 
63
67
  req.on('error', callback);
64
68
  req.on('response', function (res) {
69
+ var body = '';
70
+
71
+ res.on('data', function (chunk) {
72
+ body += chunk;
73
+ });
74
+
65
75
  res.on('end', function () {
66
- callback(null, res);
76
+ callback(null, res, body);
67
77
  });
68
78
 
69
79
  res.resume();
70
80
  });
71
81
 
72
- req.end(new Buffer(JSON.stringify(options), 'utf8'));
82
+ req.end(new Buffer.from(JSON.stringify(options), 'utf8'));
73
83
  };
74
84
 
75
85
  //
@@ -180,7 +190,7 @@ Http.prototype.query = function (options, callback) {
180
190
  //
181
191
  Http.prototype.stream = function (options) {
182
192
  options = options || {};
183
-
193
+
184
194
  var self = this,
185
195
  stream = new Stream,
186
196
  req,
@@ -6,29 +6,31 @@
6
6
  *
7
7
  */
8
8
 
9
- var fs = require('fs'),
10
- path = require('path'),
11
- common = require('./common');
12
-
13
- var transports = exports;
14
-
15
- //
16
- // Setup all transports as lazy-loaded getters.
17
- //
18
- fs.readdirSync(path.join(__dirname, 'transports')).forEach(function (file) {
19
- var transport = file.replace('.js', ''),
20
- name = common.capitalize(transport);
21
-
22
- if (transport === 'transport') {
23
- return;
9
+ Object.defineProperty(exports, 'Console', {
10
+ configurable: true,
11
+ enumerable: true,
12
+ get: function () {
13
+ return require('./transports/console').Console;
24
14
  }
25
- else if (~transport.indexOf('-')) {
26
- name = transport.split('-').map(function (part) {
27
- return common.capitalize(part);
28
- }).join('');
15
+ });
16
+ Object.defineProperty(exports, 'File', {
17
+ configurable: true,
18
+ enumerable: true,
19
+ get: function () {
20
+ return require('./transports/file').File;
29
21
  }
30
-
31
- transports.__defineGetter__(name, function () {
32
- return require('./transports/' + transport)[name];
33
- });
34
- });
22
+ });
23
+ Object.defineProperty(exports, 'Http', {
24
+ configurable: true,
25
+ enumerable: true,
26
+ get: function () {
27
+ return require('./transports/http').Http;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, 'Memory', {
31
+ configurable: true,
32
+ enumerable: true,
33
+ get: function () {
34
+ return require('./transports/memory').Memory;
35
+ }
36
+ });
@@ -9,9 +9,9 @@
9
9
  var winston = exports;
10
10
 
11
11
  //
12
- // Expose version using `pkginfo`
12
+ // use require method for webpack bundle
13
13
  //
14
- require('pkginfo')(module, 'version');
14
+ winston.version = require('../package.json').version
15
15
 
16
16
  //
17
17
  // Include transports defined by default by winston
@@ -63,7 +63,7 @@ var defaultLogger = new winston.Logger({
63
63
  });
64
64
 
65
65
  //
66
- // Pass through the target methods onto `winston.
66
+ // Pass through the target methods onto `winston`.
67
67
  //
68
68
  var methods = [
69
69
  'log',
@@ -78,9 +78,9 @@ var methods = [
78
78
  'cli',
79
79
  'handleExceptions',
80
80
  'unhandleExceptions',
81
- 'addRewriter',
82
- 'addFilter'
81
+ 'configure'
83
82
  ];
83
+ winston.padLevels = false;
84
84
  common.setLevels(winston, null, defaultLogger.levels);
85
85
  methods.forEach(function (method) {
86
86
  winston[method] = function () {