netLog
Logging network events for a session.正在记录会话的网络事件。
Process:进程:Main
const { 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)
})
See --log-net-log to log network events throughout the app's lifecycle.请参阅--log-net-log,以记录应用程序整个生命周期中的网络事件。
Note: All methods unless specified can only be used after the 除非指定,否则所有方法只能在发出ready
event of the app
module gets emitted.app
模块的ready
事件后使用。
Methods方法
netLog.startLogging(path[, options])
path
string -File path to record network logs.记录网络日志的文件路径。
Returns返回Promise<void>
- resolves when the net log has begun recording.在网络日志开始记录时解析。
Starts recording network events to 开始将网络事件记录到path
.path
。
netLog.stopLogging()
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
Readonly
A 一个boolean
property that indicates whether network logs are currently being recorded.boolean
属性,指示当前是否正在记录网络日志。