Merge remote-tracking branch 'refs/remotes/upstream/master'

Conflicts:
	lib/appenders/gelf.js
	lib/connect-logger.js
This commit is contained in:
e-cloud 2016-07-18 15:50:52 +08:00
commit 50ce5030df
3 changed files with 21 additions and 7 deletions

View File

@ -114,11 +114,11 @@ function gelfAppender(layout, host, port, hostname, facility) {
}
function sendPacket(packet) {
try {
client.send(packet, 0, packet.length, port, host);
} catch (e) {
// do nothing
}
client.send(packet, 0, packet.length, port, host, err => {
if (err) {
console.error(err);
}
});
}
return loggingEvent => {

View File

@ -135,7 +135,7 @@ function assembleTokens(req, res, customTokens) {
};
const defaultTokens = [];
defaultTokens.push({ token: ':url', replacement: req.originalUrl });
defaultTokens.push({ token: ':url', replacement: getUrl(req) });
defaultTokens.push({ token: ':protocol', replacement: req.protocol });
defaultTokens.push({ token: ':hostname', replacement: req.hostname });
defaultTokens.push({ token: ':method', replacement: req.method });
@ -186,6 +186,20 @@ function assembleTokens(req, res, customTokens) {
return arrayUniqueTokens(customTokens.concat(defaultTokens));
}
/**
* Return request url path,
* adding this function prevents the Cyclomatic Complexity,
* for the assemble_tokens function at low, to pass the tests.
*
* @param {IncomingMessage} req
* @return {String}
* @api private
*/
function getUrl(req) {
return req.originalUrl || req.url;
}
/**
* Return formatted log line.
*

View File

@ -1,6 +1,6 @@
{
"name": "log4js",
"version": "0.6.37",
"version": "0.6.38",
"description": "Port of Log4js to work with node.",
"keywords": [
"logging",