Skip to content

Commit

Permalink
Merge pull request #125 from srikanthbhadragiri/log-improvements
Browse files Browse the repository at this point in the history
Updating runtime logger calls to use logger.eventLog
  • Loading branch information
keyurkarnik authored Jul 17, 2019
2 parents 401bb29 + 97ffc4c commit 2226c2d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion analytics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports.init = function(config, logger /*, stats */) {
try {
cb(null, record);
} catch (e) {
logger.error("Error encountered processing Apigee analytics. Allowing request processing to continue", e);
logger.eventLog({level:'error', req: req, res: res, err:e, component:'analytics' },"Error encountered processing Apigee analytics. Allowing request processing to continue");
}
};

Expand Down
6 changes: 2 additions & 4 deletions apikeys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,8 @@ function sendError(req, res, next, logger, stats, code, message) {
};

debug("auth failure", res.statusCode, code, message ? message : "", req.headers, req.method, req.url);
logger.error({
req: req,
res: res
}, "apikeys");
const err = Error('auth failure');
logger.eventLog({level:'error', req: req, res: res, err:err, component:'apikeys' }, "apikeys");

//opentracing
if (process.env.EDGEMICRO_OPENTRACE) {
Expand Down
4 changes: 2 additions & 2 deletions bauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function sendError(req, res, next, logger, stats, code, message) {
error: code,
error_description: message
};

const err = Error('auth failure');
debug('auth failure', res.statusCode, code, message ? message : '', req.headers, req.method, req.url);
logger.error({ req: req, res: res }, 'oauth');
logger.eventLog({level:'error', req: req, res: res, err:err, component:'bauth' }, 'bauth');

if (!res.finished) res.setHeader('content-type', 'application/json');
res.end(JSON.stringify(response));
Expand Down
7 changes: 2 additions & 5 deletions extauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,9 @@ function sendError(req, res, next, logger, stats, code, message) {
error: code,
error_description: message
};

let err = Error(message)
debug('auth failure', res.statusCode, code, message ? message : '', req.headers, req.method, req.url);
logger.error({
req: req,
res: res
}, 'extauth');
logger.eventLog({level:'error', req: req, res: res, err:err, component:'extauth' }, 'extauth');

//opentracing
if (process.env.EDGEMICRO_OPENTRACE) {
Expand Down
7 changes: 2 additions & 5 deletions lib/basicAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,10 @@ class BasicAuthorizerPlugin {
error: code,
error_description: message
};

const err = Error(message);
debug('auth failure', res.statusCode, code, message ? message : '', req.headers, req.method, req.url);
if ( logger && logger.error && (typeof logger.error === 'function') ) {
logger.error({
req: req,
res: res
}, 'oauth');
logger.eventLog({level:'error', req: req, res: res, err:err, component:'basicAuth' }, 'oauth');
}

//opentracing
Expand Down
9 changes: 6 additions & 3 deletions oauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,15 @@ function sendError(req, res, next, logger, stats, code, message) {
error: code,
error_description: message
};

const err = Error(message);
debug('auth failure', res.statusCode, code, message ? message : '', req.headers, req.method, req.url);
if ( logger && logger.error && (typeof logger.error === 'function') ) {
logger.error({
logger.eventLog({
level:'error',
req: req,
res: res
res: res,
err: err,
component:'oauth'
}, 'oauth');
}

Expand Down
5 changes: 1 addition & 4 deletions oauthv2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ function sendError(req, res, next, logger, stats, code, message) {
};

debug('auth failure', res.statusCode, code, message ? message : '', req.headers, req.method, req.url);
logger.error({
req: req,
res: res
}, 'oauthv2');
logger.eventLog({level:'error', req: req, res: res, err:err, component:'oauthv2' }, 'oauthv2');

//opentracing
if (process.env.EDGEMICRO_OPENTRACE) {
Expand Down

0 comments on commit 2226c2d

Please sign in to comment.