mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: switch to mojo proxy resolver (3-1-x) (#15813)
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
# netLog
|
||||
|
||||
> Logging network events.
|
||||
> Logging network events for a session.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
```javascript
|
||||
const {netLog} = require('electron')
|
||||
console.log('Start recording net-logs')
|
||||
netLog.startLogging('/path/to/net-log')
|
||||
// After some network events
|
||||
netLog.stopLogging(path => {
|
||||
console.log('Net-logs written to', path)
|
||||
const { netLog } = require('electron')
|
||||
|
||||
app.on('ready', function () {
|
||||
netLog.startLogging('/path/to/net-log')
|
||||
// After some network events
|
||||
netLog.stopLogging(path => {
|
||||
console.log('Net-logs written to', path)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
See [`--log-net-log`](chrome-command-line-switches.md#--log-net-logpath) to log network events throughout the app's lifecycle.
|
||||
|
||||
**Note:** All methods unless specified can only be used after the `ready` event
|
||||
of the `app` module gets emitted.
|
||||
|
||||
## Methods
|
||||
|
||||
### `netLog.startLogging(path)`
|
||||
|
||||
@@ -426,3 +426,20 @@ app.on('ready', function () {
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
#### `ses.netLog`
|
||||
|
||||
A [NetLog](net-log.md) object for this session.
|
||||
|
||||
```javascript
|
||||
const { app, session } = require('electron')
|
||||
|
||||
app.on('ready', function () {
|
||||
const netLog = session.fromPartition('some-partition').netLog
|
||||
netLog.startLogging('/path/to/net-log')
|
||||
// After some network events
|
||||
netLog.stopLogging(path => {
|
||||
console.log('Net-logs written to', path)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user