Share
 
 

Logging

Placing logging messages at your buildstyle’s source code is always a good idea. On the one hand, you’re able to see the order of function calls. On the other hand, you get information about variable / parameter states in case your buildstyle doesn’t work like you’ve expected it to. Later on, when your buildstyle is finished, the logging messages should be deactivated, because they might increase the execution time of buildstyle processing.

Looking at the demonstration buildstyle, you’ll find a global logging switch at the main.js file:

/************************************************************
 * GLOBAL SWITCH TO ACTIVATE/DEACTIVATE DEBUG-LOGGING
 *********************************************************** */
var ENABLE_LOGGING = false;

The buildstyle methods do logging in case this logging flag is true:

exports.prepareModelExposure = function(model,
                                        attrDefaultPrinterSettings,
                                        runTests,
                                        doLogging)
{
  if(doLogging){
    var message =
 ˓→'************************************************************\nPreparing model
 ˓→exposure\n';
  }

  // Get default printer settings
  var print_settings = PRINTSETTINGS.getPrintSettings();
  // Add default settings
  model.setAttrib(attrDefaultPrinterSettings,
                  JSON.stringify(print_settings));
  if(doLogging){
    message += 'Setting default printer settings to model\n';
    process.printInfo(message);
  }
}

Was this information helpful?