var ClientLogger = function(name) { var logger = log4js.getLogger(name); return { debugl: function(fun) { if (logger.isDebugEnabled()) logger.debug.apply(logger, fun()); }, debugf: function() { logger.debug.apply(logger, arguments); }, tracef: function() { logger.trace.apply(logger, arguments); }, tracel: function(fun) { if (logger.isTraceEnabled()) logger.trace.apply(logger, fun()); }, error: function() { logger.error.apply(logger, arguments); } } }
logRequest(req) { const route = `${req.method} ${req.path}`; // We are removing credentials from req body because // POST /api/v1/registrysecrets takes credentials in its body // and we do not want to log this information to the PFE log const {credentials, ...reqBodyWithoutCredentials} = req.body; let msg = `${route} called`; if (!this.log.isTraceEnabled()) { this.log.debug(msg); } else { msg += ` with \n req.body ${util.inspect(reqBodyWithoutCredentials)}`; if (!isEmpty(req.query)) { msg += `, and \n req.query ${util.inspect(req.query)}`; } /* * we don't currently know how to log req.params automatically in Express middleware, * but you can log them manually in the .route file */ this.log.trace(msg); } }