Skip to content

Commit 6fce3f1

Browse files
committed
Merge pull request #35 from AnyFetch/restify-logger-new
Update to restify-logger 2.0.1
2 parents ba43d05 + 3e7db1e commit 6fce3f1

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

lib/middlewares/logger.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22

33
var logger = require('restify-logger');
44

5-
var filter = function filter(req, res) {
6-
return process.env.NODE_ENV !== "test" && req.method !== "OPTIONS";
7-
};
5+
logger.token('user', function(req) {
6+
return (req.token && req.token.accountName || '???') + ':';
7+
});
88

9-
var display = function display(req, res) {
10-
return (req.token && req.token.accountName) ? req.token.accountName : '???';
11-
};
9+
logger.token('append', function(req, res) {
10+
if(res.statusCode >= 400) {
11+
return res._body;
12+
}
13+
return ' ';
14+
});
1215

13-
module.exports = logger(filter, display);
16+
module.exports = logger('custom', {
17+
skip: function (req) {
18+
return process.env.NODE_ENV === "test" || req.method === "OPTIONS";
19+
}
20+
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "anyfetch-hydrater",
33
"description": "Create hydrater for AnyFetch.",
4-
"version": "1.0.11",
4+
"version": "1.0.12",
55
"author": "Matthieu Bacconnier <[email protected]>",
66
"scripts": {
77
"test": "NODE_ENV=test mocha --recursive -R spec test/",
@@ -20,7 +20,7 @@
2020
"async": "^0.9.0",
2121
"rarity": "^2.1.1",
2222
"restify": "^2.8.1",
23-
"restify-logger": "^1.0.0",
23+
"restify-logger": "^2.0.1",
2424
"supertest": "^0.13.0"
2525
},
2626
"devDependencies": {

0 commit comments

Comments
 (0)