From 1e3f35228166789d390fc254cc0ed62e234764b3 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 9 Feb 2021 01:25:11 -0500 Subject: [PATCH] openapi: Turn down logging verbosity --- src/node/hooks/express/openapi.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node/hooks/express/openapi.js b/src/node/hooks/express/openapi.js index 950b56601..bf7e5b147 100644 --- a/src/node/hooks/express/openapi.js +++ b/src/node/hooks/express/openapi.js @@ -25,7 +25,7 @@ const settings = require('../../utils/Settings'); const isValidJSONPName = require('./isValidJSONPName'); const log4js = require('log4js'); -const apiLogger = log4js.getLogger('API'); +const logger = log4js.getLogger('API'); // https://github.com/OAI/OpenAPI-Specification/tree/master/schemas/v3.0 const OPENAPI_VERSION = '3.0.2'; // Swagger/OAS version @@ -607,8 +607,9 @@ exports.expressCreateServer = (hookName, args, cb) => { const fields = Object.assign({}, header, params, query, formData); - // log request - apiLogger.info(`REQUEST, v${version}:${funcName}, ${JSON.stringify(fields)}`); + if (logger.isDebugEnabled()) { + logger.debug(`REQUEST, v${version}:${funcName}, ${JSON.stringify(fields)}`); + } // pass to api handler const data = await apiHandler.handle(version, funcName, fields, req, res).catch((err) => { @@ -623,7 +624,7 @@ exports.expressCreateServer = (hookName, args, cb) => { } else { // an unknown error happened // log it and throw internal error - apiLogger.error(err.stack || err.toString()); + logger.error(err.stack || err.toString()); throw new createHTTPError.InternalError('internal error'); } }); @@ -631,8 +632,9 @@ exports.expressCreateServer = (hookName, args, cb) => { // return in common format const response = {code: 0, message: 'ok', data: data || null}; - // log response - apiLogger.info(`RESPONSE, ${funcName}, ${JSON.stringify(response)}`); + if (logger.isDebugEnabled()) { + logger.debug(`RESPONSE, ${funcName}, ${JSON.stringify(response)}`); + } // return the response data return response;