feat: promisify netLog.stopLogging (#16862)
This commit is contained in:
parent
3b74837020
commit
7e7abc28f5
9 changed files with 78 additions and 35 deletions
|
@ -7,12 +7,11 @@ Process: [Main](../glossary.md#main-process)
|
|||
```javascript
|
||||
const { netLog } = require('electron')
|
||||
|
||||
app.on('ready', function () {
|
||||
app.on('ready', async function () {
|
||||
netLog.startLogging('/path/to/net-log')
|
||||
// After some network events
|
||||
netLog.stopLogging(path => {
|
||||
console.log('Net-logs written to', path)
|
||||
})
|
||||
const path = await netLog.stopLogging()
|
||||
console.log('Net-logs written to', path)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -36,6 +35,14 @@ Starts recording network events to `path`.
|
|||
|
||||
Stops recording network events. If not called, net logging will automatically end when app quits.
|
||||
|
||||
**[Deprecated Soon](promisification.md)**
|
||||
|
||||
### `netLog.stopLogging()`
|
||||
|
||||
Returns `Promise<String>` - resolves with a file path to which network logs were recorded.
|
||||
|
||||
Stops recording network events. If not called, net logging will automatically end when app quits.
|
||||
|
||||
## Properties
|
||||
|
||||
### `netLog.currentlyLogging`
|
||||
|
|
|
@ -15,7 +15,6 @@ When a majority of affected functions are migrated, this flag will be enabled by
|
|||
- [dialog.showCertificateTrustDialog([browserWindow, ]options, callback)](https://github.com/electron/electron/blob/master/docs/api/dialog.md#showCertificateTrustDialog)
|
||||
- [inAppPurchase.purchaseProduct(productID, quantity, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#purchaseProduct)
|
||||
- [inAppPurchase.getProducts(productIDs, callback)](https://github.com/electron/electron/blob/master/docs/api/in-app-purchase.md#getProducts)
|
||||
- [netLog.stopLogging([callback])](https://github.com/electron/electron/blob/master/docs/api/net-log.md#stopLogging)
|
||||
- [ses.getCacheSize(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#getCacheSize)
|
||||
- [ses.clearCache(callback)](https://github.com/electron/electron/blob/master/docs/api/session.md#clearCache)
|
||||
- [ses.clearStorageData([options, callback])](https://github.com/electron/electron/blob/master/docs/api/session.md#clearStorageData)
|
||||
|
@ -46,6 +45,7 @@ When a majority of affected functions are migrated, this flag will be enabled by
|
|||
- [cookies.set(details, callback)](https://github.com/electron/electron/blob/master/docs/api/cookies.md#set)
|
||||
- [debugger.sendCommand(method[, commandParams, callback])](https://github.com/electron/electron/blob/master/docs/api/debugger.md#sendCommand)
|
||||
- [desktopCapturer.getSources(options, callback)](https://github.com/electron/electron/blob/master/docs/api/desktop-capturer.md#getSources)
|
||||
- [netLog.stopLogging([callback])](https://github.com/electron/electron/blob/master/docs/api/net-log.md#stopLogging)
|
||||
- [protocol.isProtocolHandled(scheme, callback)](https://github.com/electron/electron/blob/master/docs/api/protocol.md#isProtocolHandled)
|
||||
- [shell.openExternal(url[, options, callback])](https://github.com/electron/electron/blob/master/docs/api/shell.md#openExternal)
|
||||
- [webviewTag.capturePage([rect, ]callback)](https://github.com/electron/electron/blob/master/docs/api/webview-tag.md#capturePage)
|
||||
|
|
|
@ -462,12 +462,11 @@ A [NetLog](net-log.md) object for this session.
|
|||
```javascript
|
||||
const { app, session } = require('electron')
|
||||
|
||||
app.on('ready', function () {
|
||||
app.on('ready', async 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)
|
||||
})
|
||||
const path = await netLog.stopLogging()
|
||||
console.log('Net-logs written to', path)
|
||||
})
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue