aboutsummaryrefslogtreecommitdiffstats
path: root/lib/logging.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/logging.js')
-rw-r--r--lib/logging.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/logging.js b/lib/logging.js
index 4d85898..a21f37e 100644
--- a/lib/logging.js
+++ b/lib/logging.js
@@ -140,7 +140,7 @@ const formatAuditRecord = function(req, status, extra) {
rec[AUDIT_CATLOGLEVEL] = "INFO"; // The audit records are informational, regardless of the outcome of the operation
rec[AUDIT_SRVIP] = req.socket.address().address;
rec[AUDIT_ELAPSED] = end - req.startTime;
- rec[AUDIT_SERVER] = req.hostname // From the Host header, again
+ rec[AUDIT_SERVER] = req.hostname; // From the Host header, again
rec[AUDIT_CLIENTIP] = req.connection.remoteAddress;
if (extra) {
@@ -169,8 +169,9 @@ const formatMetricsRecord = function(req, opInfo, extra) {
rec[METRICS_REQID] = req.dcaeReqId;
rec[METRICS_SRVNAME] = req.hostname; // Use name from the host header
rec[METRICS_SVCNAME] = req.method + ' ' + req.originalUrl; // Method and URL identify the operation being performed
- rec[METRICS_CLIENTIP] = req.connection.remoteAddress;
- rec[METRICS_SRVIP] = req.socket.address().address;
+ /* Defense: some clients will pass in a req that's incomplete */
+ if (req.connection) {rec[METRICS_CLIENTIP] = req.connection.remoteAddress;}
+ if (req.socket) {rec[METRICS_SRVIP] = req.socket.address().address;}
}
else {
/* No incoming request */
@@ -259,7 +260,7 @@ exports.getLogger = function() {
debug: function(reqId, msg) {
debugLogger.debug(formatDebugRecord(reqId, msg));
}
- }
+ };
};
exports.setLevel = function(level) {