E-Mail Kontakt - Tel: 02192 / 91 89 921
    Impressum | Datenschutz

Log++ is a comfortable Google Ads Scripts Logging lib

Log.timestamp("any debuginfo") prints for example any debuginfo.

Integration in an Google Ads Script

 bDiLogger = true; // set to false => logging via Log is completely disabled
                   // This way you don't need to remove your logging code:-)
 Log = (bDiLogger === true) ? (function() {eval(UrlFetchApp.fetch("http://tools.internet-marketing-inside.de/adwords-scripts-dilogger.js").getContentText());return new DiLogger();})() : {__noSuchMethod__: function() {}};

If you want to disable logging just set bDiLogger=false!

Some examples

bDiLogger = true; // set to false => logging via Log is completely disabled
                  // This way you don't need to remove your logging code:-)
Log = (bDiLogger === true) ? (function() {eval(UrlFetchApp.fetch("http://tools.internet-marketing-inside.de/adwords-scripts-dilogger.js").getContentText());return new DiLogger();})() : {__noSuchMethod__: function() {}};


function main() {
  Log.datetime("start"); // => "2017-04-07 13:39:37 start"
  
  // ## print the time elapsed since start and then the argument
  Log.elapsed("runtime1"); // => "00:00 runtime1"
  Utilities.sleep(5000);
  Log.elapsed("runtime2"); // => "00:05 runtime2"  
  Utilities.sleep(25000);
  Log.elapsed("runtime3"); // => "00:30 runtime3"    
 
  // ## print second argument every 3 times if the first argument is "AAA"
  Log.count("AAA", "a1", 3); // => Logger.log("a1")   first call will alway be logged
  Log.count("AAA", "a2", 3); // no output
  Log.count("AAA", "a3", 3); // => "a3"
  Log.count("AAA", "a4", 3); // no output
  Log.count("AAA", "a5", 3); // no output
  Log.count("AAA", "a6", 3); // => "a6"
 
  // ## print second argument every 2 times if the first argument is "BBB". Now print id and count as well
  Log.count("BBB", "b1", 2, true); // "BBB->1: b1"    first call will alway be logged
  Log.count("BBB", "b2", 2, true); // "BBB->2: b2"
  Log.count("BBB", "b3", 2, true); // no output
  Log.count("BBB", "b4", 2, true); // "BBB->4: b4"
  
  Log.time("end1"); // => "13:40:47 end1"
  Log.datetime("end2"); // => "2017-04-07 13:40:47 end2"
 
  // ####################
  Logger.log(AccountTime.timestamp()); // "2017-04-07 13:40:47.123"
  
  // ####################
  var sw = Log.getStopwatch();
  Utilities.sleep(2000);
  Logger.log(sw.elapsedMinSec()); // "00:02"
}