Use logging implementation with late string composition

Idea ID 1766516

Use logging implementation with late string composition

Service Manager includes a lot of different logging implementations - and many are building output string before it is tested, if the message should be logged because of log level.

A simple implementation and quickly to fix can be found here:

ScriptLibrary htmlemailtemplates

The log is written by this function:

function logMsg(type, app, step, msg) {  
     var debug="off";
     if ((type == "DEBUG") && (debug != "on")) {
         return "";
     }
     var rc = system.functions.log(type + ";" + app + ";" + step + ";" + msg);
}

Example about how this is called:

function getMailHeader(templateName, $RECORD, $RECORDOLD, recipient, lang) {

var logMsgStep="getMailHeader";
logMsg("DEBUG", logMsgApp, logMsgStep, "Start: " + recipient);
logMsg("DEBUG", logMsgApp, logMsgStep, "record: " + $RECORD);
logMsg("DEBUG", logMsgApp, logMsgStep, "RECORDOLD: " + $RECORDOLD);

return getTemplate(templateName, $RECORD, $RECORDOLD, recipient, lang, "subject");
}

What's the issue:

When logMsg() is called, the string to print is already built: This requires i.e. conversion of a file variable to a string - and this takes time. Logging a lot or of larger objects is wasting significant time.

 

The idea is to reimplement logMsg() like this:

function logMsg( type )
{
    if ((type == "DEBUG") && (debug != "on")) {
            return "";
      }
      
      var rc = system.functions.log(Array.prototype.join.call(arguments));
}

The call will change to:

logMsg("DEBUG", logMsgApp, logMsgStep, " $RECORD", $RECORD);

With the effect that the arguments

 

 

This refers to

QCCR1E134469 Refactor log invoking code to improve function

and

https://docs.microfocus.com/SM/9.61/Codeless/Content/programming/javascript/concepts/implementing_custom_logging.htm

 

Tags (1)
3 Comments
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor
Status changed to: Waiting for Votes
 
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor
Status changed to: Accepted

Great news, this idea has been accepted on our product roadmap, timing TBD. Check back for updates. (This is not a formal commitment, and subject to change)

Micro Focus Frequent Contributor
Micro Focus Frequent Contributor
Status changed to: Under Consideration
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.