lib/logger.js
/**
 * @brief This function sets up the bunyan logger object based on the given
 *        configuration.
 *
 * @return object log utility object with following methods:
 *                - create
 *                - logRequest
 */
@brief This function sets up the bunyan logger object based on the given
configuration.

@return object log utility object with following methods:
- create
- logRequest
@brief This function sets up the bunyan logger object based on the given configuration . @return object log utility object with following methods : - create - logRequest
function initializeLogger() {
    'use strict';
    const bunyan = require('bunyan');
    const config = require('../config');
    const constants = require('./constants');
    let logger;
    function create() {
        if (logger !== undefined) {
            return logger;
        }
        logger = bunyan.createLogger({
            name: constants.appName,
            level: config.LOG_LEVEL,
            src: true
        });
        return logger;
    }
    function logRequest(req, ignore, next) {
        logger.info({requestBody: req.body}, "Incoming request.");
        next();
    }
    return Object.freeze({
        create,
        logRequest
    });
}
function initializeLogger ( ) { 'use strict' ; const bunyan = require ( 'bunyan' ) ; const config = require ( '../config' ) ; const constants = require ( './constants' ) ; let logger ; function create ( ) { if ( logger !== undefined ) { return logger ; } logger = bunyan . createLogger ( { name : constants . appName , level : config . LOG_LEVEL , src : true } ) ; return logger ; } function logRequest ( req , ignore , next ) { logger . info ( { requestBody : req . body } , "Incoming request." ) ; next ( ) ; } return Object . freeze ( { create , logRequest } ) ; }
@brief This function sets up the bunyan logger object based on the given
        configuration.
@brief This function sets up the bunyan logger object based on the given configuration .
// Get current configuration. // Logger object. /**
     * @brief Main function responsible for creating the logger or returning the
     *        existing logger.
     *
     * @return object bunyan logger object
     */ // Logger already created. // Create bunyan logger. /**
     * @brief Middleware function to log each incoming request.
     *
     * @param req express http request object
     * @param ignore
     * @param next express next function
     *
     * @return none
     */ // Runs the next middleware function.