netLog
记录会话的网络事件。
进程:主进程
🌐 Process: Main
const { app, netLog } = require('electron')
app.whenReady().then(async () => {
await netLog.startLogging('/path/to/net-log')
// After some network events
const path = await netLog.stopLogging()
console.log('Net-logs written to', path)
})
请参阅 --log-net-log 以在应用的整个生命周期中记录网络事件。
🌐 See --log-net-log to log network events throughout the app's lifecycle.
除非另有说明,所有方法只能在 app 模块发出 ready 事件之后使用。
方法
🌐 Methods
netLog.startLogging(path[, options])
path字符串 - 用于记录网络日志的文件路径。
返回 Promise<void> - 当网络日志开始记录时解析。
🌐 Returns Promise<void> - resolves when the net log has begun recording.
开始将网络事件记录到 path。
🌐 Starts recording network events to path.
netLog.stopLogging()
返回 Promise<void> —— 在网络日志已刷新到磁盘后解决。
🌐 Returns Promise<void> - resolves when the net log has been flushed to disk.
停止记录网络事件。如果不调用此操作,网络日志将在应用退出时自动结束。
🌐 Stops recording network events. If not called, net logging will automatically end when app quits.
属性
🌐 Properties
netLog.currentlyLogging 只读
🌐 netLog.currentlyLogging Readonly
boolean 属性,指示网络日志当前是否正在记录。
🌐 A boolean property that indicates whether network logs are currently being recorded.