so my problem is that I want to log any request to my sails app. Basically I've got it working with the one problem that I can't log the params of the request.
myRequestLogger: function(req, res, next) {
if (sails.config.environment === 'development') {
console.log('=========================================================');
console.log("Request :: ", req.method, req.url, req.param);
console.log('=========================================================');
}
return next();
},
req.allParams() returns it isn't a function and req.param(...) returns undefined. Do I have to impement this in another position? Does anybody knows what I'm doing wrong?
Bruno
EDIT
I use the default order inside the http.js :
order: [
'startRequestTimer',
'cookieParser',
'session',
'passportInit',
'passportSession',
'myRequestLogger',
'bodyParser',
'handleBodyParserError',
'compress',
'methodOverride',
'poweredBy',
'$custom',
'router',
'www',
'favicon',
'404',
'500'
]
Found the answer ... The order has to be different. The requestLogger has to be implemented after the bodyParser:
order: [
...
'bodyParser',
'myRequestLogger',
'handleBodyParserError',
'...
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.