netLog
Logging network events for a session.
Processo: 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)
})
See --log-net-log
to log network events throughout the app's lifecycle.
Nota: Todos os métodos, a menos que seja especificados, só podem ser usados após o evento app
quando é emitido.
Métodos
netLog.startLogging(path[, options])
path
string - File path to record network logs.- Objeto
options
(opcional)captureMode
string (optional) - What kinds of data should be captured. By default, only metadata about requests will be captured. Setting this toincludeSensitive
will include cookies and authentication data. Setting it toeverything
will include all bytes transferred on sockets. Can bedefault
,includeSensitive
oreverything
.maxFileSize
number (optional) - When the log grows beyond this size, logging will automatically stop. Defaults to unlimited.
Returns Promise<void>
- resolves when the net log has begun recording.
Starts recording network events to 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.
Propriedades
netLog.currentlyLogging
Readonly
A boolean
property that indicates whether network logs are currently being recorded.