How to debug Google Apps Script (aka where does Logger.log log to?)

前端 未结 12 1822
时光说笑
时光说笑 2020-12-12 11:25

In Google Sheets, you can add some scripting functionality. I\'m adding something for the onEdit event, but I can\'t tell if it\'s working. As far as I can tell

12条回答
  •  北海茫月
    2020-12-12 12:03

    It's far from elegant, but while debugging, I often log to the Logger, and then use getLog() to fetch its contents. Then, I either:

    • save the results to a variable (which can be inspected in the Google Scripts debugger—this works around cases where I can't set a breakpoint in some code, but I can set one in code that gets executed later)
    • write it to some temporary DOM element
    • display it in an alert

    Essentially, it just becomes a JavaScript output issue.

    It grossly lacks the functionality of modern console.log() implementations, but the Logger does still help debug Google Scripts.

提交回复
热议问题