我编写了我的第一个*.gs
Google Ads 脚本文件。
是否有任何 IDE 或环境可以添加断点或查看变量状态?
我只看到记录器打印,但使用起来效率不高。
我已经尝试过@Andrew 的回复,但没有成功:
我编写了我的第一个*.gs
Google Ads 脚本文件。
是否有任何 IDE 或环境可以添加断点或查看变量状态?
我只看到记录器打印,但使用起来效率不高。
我已经尝试过@Andrew 的回复,但没有成功:
你可以使用这个功能。
例如:MyLogger("test");
function MyLogger(s,d=true,w=800,h=400,t=5) {
const cs=CacheService.getScriptCache();
const cached=cs.get("Logger");
const ts=Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "MM|dd|HH:mm:ss")
if(cached) {
var v=Utilities.formatString('%s<br />[%s] - %s',cached,ts,s);
}else{
var v=Utilities.formatString('[%s] - %s',ts,s);
}
cs.put("Logger",v,t);
//allows logging without displaying.
if(d) {
const a='<br /><input type="button" value="Exit" onClick="google.script.host.close();" />';
const b='<br /><input type="button" value="Exit" onClick="google.script.host.close();" /><br />';
SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(b+v+a).setWidth(w).setHeight(h), 'My Logger');
}
}
(要查看日志,请使用您的脚本打开电子表格)