Idea ID: 1766516

Use logging implementation with late string composition

Status : Under Consideration
over 2 years ago

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(;

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