Replace log4js by pino as logger:
- Logs to stdout, disabled while testing - Change log calls signature when needed - Use development version of camshaft - Removes unused log cofiguration - Bind request id to log req/res - Log req at the begining of the cycle and res at the end
This commit is contained in:
@@ -10,17 +10,20 @@ module.exports = CdbRequest;
|
||||
|
||||
CdbRequest.prototype.userByReq = function (req) {
|
||||
var host = req.headers.host || '';
|
||||
|
||||
if (req.params.user) {
|
||||
return req.params.user;
|
||||
}
|
||||
|
||||
var mat = host.match(this.RE_USER_FROM_HOST);
|
||||
|
||||
if (!mat) {
|
||||
global.logger.error("Pattern '%s' does not match hostname '%s'", this.RE_USER_FROM_HOST, host);
|
||||
return;
|
||||
return global.logger.error(new Error(`Pattern '${this.RE_USER_FROM_HOST}' does not match hostname '${host}'`));
|
||||
}
|
||||
|
||||
if (mat.length !== 2) {
|
||||
global.logger.error("Pattern '%s' gave unexpected matches against '%s': %s", this.RE_USER_FROM_HOST, host, mat);
|
||||
return;
|
||||
return global.logger.error(new Error(`Pattern '${this.RE_USER_FROM_HOST}' gave unexpected matches against '${host}': ${mat}`));
|
||||
}
|
||||
|
||||
return mat[1];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user