Home > database >  Why doesn't Logger.log work any more with HTML Service
Why doesn't Logger.log work any more with HTML Service

Time:01-21

Recently I notice that Logger.log is not working if a function is called from HTML Service.

In my HTML :

google.script.run.withSuccessHandler(
  function(text) {
    alert(text);
  }
).setColors(checked);

In Code.gs:

function setColors(checked) {
  try {
    Logger.log(checked);
    return "hello";
  }
  catch(err) {
    Logger.log(err);
  }
}

The "hello" is returned but the log is empty, or actually its a log from a previous test function unrelated. And "checked" is displayed in an alert box after google.script.run and its correct.

CodePudding user response:

If you are using new editor, in "Executions" menu you need to look for last executed function, which suppose to log. In your case setColors(). If nothing have been logged, give some time and try refreshing. It hints, that it takes some time for logs to appear.

CodePudding user response:

My problem was my reluctance to use the new editor because of the issue with delay in Logger.log. But now I can see a lot of advantages to using the new editor, although it takes some exploration and effort to find how to do things like find and replace.

But there are a lot of advantages to the new editor and console.log and exection log for debugging. console.log is displayed in the editor along with the code for stand alone running and debugging of scripts. And the console.log and execution log work for HTML service request. So for now I'm a happy camper :)

  •  Tags:  
  • Related