久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用chrome或firefox在javascript中將console.trace(

How to get result of console.trace() as string in javascript with chrome or firefox?(如何使用chrome或firefox在javascript中將console.trace()的結(jié)果作為字符串?)
本文介紹了如何使用chrome或firefox在javascript中將console.trace()的結(jié)果作為字符串?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

console.trace() 在控制臺上輸出結(jié)果.
我想以字符串形式獲取結(jié)果并將它們保存到文件中.

我沒有為函數(shù)定義名稱,也無法使用 callee.caller.name 獲取它們的名稱.

console.trace() outputs its result on console.
I want to get the results as string and save them to a file.

I don't define names for functions and I also can not get their names with callee.caller.name.

推薦答案

我不確定 firefox,但在 v8/chrome 中,您可以在 Error 構(gòu)造函數(shù)上使用名為 captureStackTrace 的方法.(更多信息在這里)

I'm not sure about firefox, but in v8/chrome you can use a method on the Error constructor called captureStackTrace. (More info here)

因此,獲得它的一種 hacky 方法是:

So a hacky way to get it would be:

var getStackTrace = function() {
  var obj = {};
  Error.captureStackTrace(obj, getStackTrace);
  return obj.stack;
};

console.log(getStackTrace());

通常,getStackTrace 在被捕獲時會在堆棧上.那里的第二個參數(shù)將 getStackTrace 排除在堆棧跟蹤中.

Normally, getStackTrace would be on the stack when it's captured. The second argument there excludes getStackTrace from being included in the stack trace.

這篇關于如何使用chrome或firefox在javascript中將console.trace()的結(jié)果作為字符串?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創(chuàng)建子窗口時如何修復 BrowserWindow 不是構(gòu)造函數(shù)錯誤) - IT屋-程序員軟件開發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網(wǎng)絡攝像頭?)
主站蜘蛛池模板: 美日韩一区二区 | 一级网站 | 成人精品在线视频 | 99久久国产| 亚洲精品久久久久久久久久吃药 | 国产精品视频在线观看 | 欧美黄色免费网站 | 羞羞在线观看视频 | 国产精品久久久久久久久久东京 | 色伊人久久 | 国产精品一区二 | 国产成人在线观看免费 | 日韩久久综合网 | 91欧美激情一区二区三区成人 | 久久久精品影院 | 国产精品视频一 | 国产精品久久久久久婷婷天堂 | 久久综合一区 | 人人射人人插 | 看片91| 日日日色 | 欧美一区| 日韩精品一区二区三区 | 五月天综合网 | 欧美视频精品 | 久久国产精品视频 | 久久精品亚洲一区二区三区浴池 | 视频在线观看一区 | 91一区二区三区在线观看 | 欧美a∨| 男人的天堂视频网站 | 国产在线精品一区 | 色约约视频 | 亚洲国产精品久久久 | 国产精品99久久久久久动医院 | 欧美日韩在线看 | 国产精品18毛片一区二区 | 亚洲视频免费观看 | 免费的一级视频 | 亚洲成在线观看 | 国产精品一区二区免费 |