2014-05-09 23:23:41 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-10-24 05:13:43 +04:00
|
|
|
const logger = require('./')('summary');
|
2014-05-09 23:23:41 +04:00
|
|
|
|
|
|
|
module.exports = function summary(request, response) {
|
|
|
|
if (request.method === 'options') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var payload = request.payload || {};
|
|
|
|
var query = request.query || {};
|
|
|
|
var params = request.params || {};
|
|
|
|
|
2014-11-11 01:20:00 +03:00
|
|
|
var auth = request.auth && request.auth.credentials && {
|
|
|
|
user: request.auth.credentials.user,
|
|
|
|
scope: request.auth.credentials.scope
|
|
|
|
};
|
|
|
|
|
2014-05-09 23:23:41 +04:00
|
|
|
var line = {
|
|
|
|
code: response.isBoom ? response.output.statusCode : response.statusCode,
|
|
|
|
errno: response.errno || 0,
|
2014-11-11 01:20:00 +03:00
|
|
|
method: request.method,
|
2014-05-09 23:23:41 +04:00
|
|
|
path: request.path,
|
|
|
|
agent: request.headers['user-agent'],
|
|
|
|
t: Date.now() - request.info.received,
|
2014-11-11 01:20:00 +03:00
|
|
|
client_id: payload.client_id || query.client_id || params.client_id,
|
|
|
|
auth: auth,
|
|
|
|
payload: Object.keys(payload)
|
2014-05-09 23:23:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (line.code >= 500) {
|
|
|
|
line.stack = response.stack;
|
2014-11-20 03:25:48 +03:00
|
|
|
logger.error('summary', line);
|
2014-05-09 23:23:41 +04:00
|
|
|
} else {
|
2014-11-20 03:25:48 +03:00
|
|
|
logger.info('summary', line);
|
2014-05-09 23:23:41 +04:00
|
|
|
}
|
|
|
|
};
|