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

前端 未结 12 1819
时光说笑
时光说笑 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条回答
  •  -上瘾入骨i
    2020-12-12 12:02

    2017 Update: Stackdriver Logging is now available for Google Apps Script. From the menu bar in the script editor, goto: View > Stackdriver Logging to view or stream the logs.

    console.log() will write DEBUG level messages

    Example onEdit() logging:

    function onEdit (e) {
      var debug_e = {
        authMode:  e.authMode,  
        range:  e.range.getA1Notation(),    
        source:  e.source.getId(),
        user:  e.user,   
        value:  e.value,
        oldValue: e. oldValue
      }
    
      console.log({message: 'onEdit() Event Object', eventObject: debug_e});
    }
    

    Then check the logs in the Stackdriver UI labeled onEdit() Event Object to see the output

提交回复
热议问题