非常慢的“日志"使用Google Apps Script V8与Rhino? [英] Very slow "Logs" with Google Apps Script V8 vs Rhino?

查看:70
本文介绍了非常慢的“日志"使用Google Apps Script V8与Rhino?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Rhino,日志"对话框(命令+输入"或查看"菜单中的日志")立即显示日志.但是,对于使用V8引擎的测试项目,即使是最简单的日志,也需要10到20秒的时间来加载,并显示一条消息正在等待日志,请稍候..."

With Rhino, Logs dialog ("command + Enter" or Logs from View menu) shows logs instantly. However, with test projects using V8 engine it takes 10-20 seconds to load even the simplest logs, with a message "Waiting for logs, please wait..."

"Logger.log"或"console.log"加载日志都很慢.还有其他人遇到过相同类型的缓慢情况吗?新引擎会出现这种情况吗?

Both, "Logger.log" or "console.log" are slow to load logs. Is anyone else experiencing the same type of slowness? Is this expected with the new engine?

提前谢谢!

这是我用于测试的基本功能:

Here's a basic function I used for testing:

function logTest() {
 Logger.log("log test");
}

推荐答案

我注意到了同一件事,并且已经有一个问题.

I noticed the same thing and there is an issue about it already.

我一直在使用以下脚本.它可能不是防弹的,但对我来说,比等待日志要好.我还注意到,如果您出错了,请转到查看执行",即使在脚本编辑器上获取日志之前,日志现在似乎也已出现在此处.

I've been using the below script. It's probably not bullet proof but for me it's better than waiting for the log. I also notice that if you have an error and go to View Executions that the logs appear to come out there now even before we get them on the script editor.

问题链接: https://issuetracker.google.com/issues/149519063

function MyLogger(s,t=5) {
  const cs=CacheService.getScriptCache();
  const cached=cs.get("Logger");
  const ts=Utilities.formatDate(new Date(), SpreadsheetApp.getActive().getSpreadsheetTimeZone(), "yy/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);
  SpreadsheetApp.getUi().showModelessDialog(HtmlService.createHtmlOutput(v), 'My Logger');
}

MyLogger()的另一个版本:

Another version of MyLogger():

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');
  }
}

这篇关于非常慢的“日志"使用Google Apps Script V8与Rhino?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆