winston-middleware 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/Readme.md +14 -7
  2. package/index.js +2 -1
  3. package/package.json +1 -1
package/Readme.md CHANGED
@@ -17,7 +17,7 @@ Use `expressWinston.errorLogger(options)` to create a middleware that log the er
17
17
 
18
18
  ``` js
19
19
  app.use(app.router); // notice how the router goes first.
20
- app.use(expressWinston.errorHandler({
20
+ app.use(expressWinston.errorLogger({
21
21
  transports: [
22
22
  new winston.transports.Console({
23
23
  json: true,
@@ -29,6 +29,13 @@ Use `expressWinston.errorLogger(options)` to create a middleware that log the er
29
29
 
30
30
  The logger needs to be added AFTER the express router(`app.router)`) and BEFORE any of your custom error handlers(`express.handler`). Since winston-middleware will just log the errors and not __handle__ them, you can still use your custom error handler like `express.handler`, just be sure to put the logger before any of your handlers.
31
31
 
32
+ ### Options
33
+
34
+ ``` js
35
+ transports: [<WinstonTransport>], // list of all winston transports instances to use.
36
+ level: String // log level to use, the default is "info".
37
+ ```
38
+
32
39
  ### Request Logging
33
40
 
34
41
  Use `expressWinston.logger(options)` to create a middleware to log your HTTP requests.
@@ -69,8 +76,8 @@ Use `expressWinston.logger(options)` to create a middleware to log your HTTP req
69
76
 
70
77
  app.use(app.router);
71
78
 
72
- // winston-middleware errorHandler makes sense AFTER the router.
73
- app.use(expressWinston.errorHandler({
79
+ // winston-middleware errorLogger makes sense AFTER the router.
80
+ app.use(expressWinston.errorLogger({
74
81
  transports: [
75
82
  new winston.transports.Console({
76
83
  json: true,
@@ -80,7 +87,7 @@ Use `expressWinston.logger(options)` to create a middleware to log your HTTP req
80
87
  }));
81
88
 
82
89
  // Optionally you can include your custom error handler after the logging.
83
- app.use(express.errorHandler({
90
+ app.use(express.errorLogger({
84
91
  dumpExceptions: true,
85
92
  showStack: true
86
93
  }));
@@ -205,17 +212,17 @@ Browse `/error` will show you how winston-middleware handles and logs the errors
205
212
 
206
213
  ## Issues and Collaboration
207
214
 
208
- * Add option to set the log level.
209
215
  * Add support for filtering of __req.body__. At this moment `body` is not included in the logging because it can contain sensitive fields like 'password' or 'password_confirmation'.
210
216
  * Implement a chain of requestFilters. Currently only one requestFilter is allowed in the options.
211
217
 
212
- We are accepting pull-request for this features.
218
+ We are accepting pull-request for these features.
213
219
 
214
220
  If you ran into any problems, please use the project [Issues section](https://github.com/firebaseco/winston-middleware/issues) to search or post any bug.
215
221
 
216
222
  ## Contributors
217
223
 
218
- * Johan (author). Email: *johan@firebase.co*
224
+ * [Johan Hernandez](https://github.com/thepumpkin1979). [https://github.com/thepumpkin1979](https://github.com/thepumpkin1979)
225
+ * [Lars Jacob]((https://github.com/jaclar)) [https://github.com/jaclar)](https://github.com/jaclar)
219
226
 
220
227
  ## MIT License
221
228
 
package/index.js CHANGED
@@ -80,6 +80,7 @@ function logger(options) {
80
80
  if(!options) throw new Error("options are required by winston-middleware middleware");
81
81
  if(!options.transports || !(options.transports.length > 0)) throw new Error("transports are required by winston-middleware middleware");
82
82
  options.requestFilter = options.requestFilter || defaultRequestFilter;
83
+ options.level = options.level || "info";
83
84
  return function(req, res, next) {
84
85
  var meta = {
85
86
  req: filterRequest(req, options.requestFilter)
@@ -87,7 +88,7 @@ function logger(options) {
87
88
  var msg = util.format("HTTP %s %s", req.method, req.url);
88
89
 
89
90
  function logOnTransport(transport, nextTransport) {
90
- return transport.log('info', msg, meta, nextTransport);
91
+ return transport.log(options.level, msg, meta, nextTransport);
91
92
  };
92
93
 
93
94
  function done() {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "winston-middleware",
4
4
  "description": "express.js middleware for flatiron/winston",
5
5
  "keywords": ["winston", "flatiron", "logging", "express", "log", "error", "handler", "middleware"],
6
- "version": "0.1.1",
6
+ "version": "0.1.3",
7
7
  "repository": {
8
8
  "url": "https://github.com/firebaseco/winston-middleware.git"
9
9
  },