lib/logger/lib/logger.js
function (level, message, tag, data) {

        var env = Shared.config('environment');
        var levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'];
        var logLevelConfig = env.logLevel || "info";

        if (logLevelConfig == "none") {
            return;
        }

        var logLevel = levels.indexOf(logLevelConfig) >= 0 ? logLevelConfig : 'info';

        // Set default error logging
        if (_.isObject(message) && _.isEmpty(data)) {
            if (message.message && _.isString(message.message)) {
                data = message.stack || "";
                message = message.message;
            }
            else {
                data = message;
                message = null;
            }
        }

        //Output
        if (levels.indexOf(level) <= levels.indexOf(logLevel)) {
            var logString = "";

            if (env.logFormat === 'json') {
                logString = JSON.stringify({
                    timestamp: new Date().toISOString(),
                    level,
                    tag,
                    message,
                    data,
                    hostname: Shared.getCurrentHostId(),
                    pid: process.pid,
                    mode: env.mode
                });
            } else {
                if (_.isObject(data)) {
                    data = Util.inspect(data, {showHidden: false, depth: null});
                }

                logString += new Date().toISOString() + ' ';
                logString += '[' + level + ']';
                logString += tag == "default" ? "" : ' [' + tag + ']';
                logString += !_.isString(message) ? "" : ': ' + message;
                logString += data ? ' --> ' + data : "";
            }

            if (["error", "fatal"].indexOf(level) >= 0) {
                _outputLog("error", logString);
            } else if (level == "warn") {
                _outputLog("warn", logString);
            } else {
                _outputLog("info", logString);
            }
        }
    }
function (level, message, tag, data) {

        var env = Shared.config('environment');
        var levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'];
        var logLevelConfig = env.logLevel || "info";

        if (logLevelConfig == "none") {
            return;
        }

        var logLevel = levels.indexOf(logLevelConfig) >= 0 ? logLevelConfig : 'info';

        // Set default error logging
        if (_.isObject(message) && _.isEmpty(data)) {
            if (message.message && _.isString(message.message)) {
                data = message.stack || "";
                message = message.message;
            }
            else {
                data = message;
                message = null;
            }
        }

        //Output
        if (levels.indexOf(level) <= levels.indexOf(logLevel)) {
            var logString = "";

            if (env.logFormat === 'json') {
                logString = JSON.stringify({
                    timestamp: new Date().toISOString(),
                    level,
                    tag,
                    message,
                    data,
                    hostname: Shared.getCurrentHostId(),
                    pid: process.pid,
                    mode: env.mode
                });
            } else {
                if (_.isObject(data)) {
                    data = Util.inspect(data, {showHidden: false, depth: null});
                }

                logString += new Date().toISOString() + ' ';
                logString += '[' + level + ']';
                logString += tag == "default" ? "" : ' [' + tag + ']';
                logString += !_.isString(message) ? "" : ': ' + message;
                logString += data ? ' --> ' + data : "";
            }

            if (["error", "fatal"].indexOf(level) >= 0) {
                _outputLog("error", logString);
            } else if (level == "warn") {
                _outputLog("warn", logString);
            } else {
                _outputLog("info", logString);
            }
        }
    }
function ( level , message , tag , data ) { var env = Shared . config ( 'environment' ) ; var levels = [ 'fatal' , 'error' , 'warn' , 'info' , 'debug' , 'trace' ] ; var logLevelConfig = env . logLevel || "info" ; if ( logLevelConfig == "none" ) { return ; } var logLevel = levels . indexOf ( logLevelConfig ) >= 0 ? logLevelConfig : 'info' ; // Set default error logging if ( _ . isObject ( message ) && _ . isEmpty ( data ) ) { if ( message . message && _ . isString ( message . message ) ) { data = message . stack || "" ; message = message . message ; } else { data = message ; message = null ; } } //Output if ( levels . indexOf ( level ) <= levels . indexOf ( logLevel ) ) { var logString = "" ; if ( env . logFormat === 'json' ) { logString = JSON . stringify ( { timestamp : new Date ( ) . toISOString ( ) , level , tag , message , data , hostname : Shared . getCurrentHostId ( ) , pid : process . pid , mode : env . mode } ) ; } else { if ( _ . isObject ( data ) ) { data = Util . inspect ( data , { showHidden : false , depth : null } ) ; } logString += new Date ( ) . toISOString ( ) + ' ' ; logString += '[' + level + ']' ; logString += tag == "default" ? "" : ' [' + tag + ']' ; logString += ! _ . isString ( message ) ? "" : ': ' + message ; logString += data ? ' --> ' + data : "" ; } if ( [ "error" , "fatal" ] . indexOf ( level ) >= 0 ) { _outputLog ( "error" , logString ) ; } else if ( level == "warn" ) { _outputLog ( "warn" , logString ) ; } else { _outputLog ( "info" , logString ) ; } } }
Write logging information
@param level => 'none', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'
@param message = >Error message
@param tag => Tags of log info i.e. database, request. Default is 'default' or empty
@param data => Any data object
@private
Write logging information