Use content tracing after app ready

This commit is contained in:
Kevin Sawicki 2017-02-02 13:20:38 -08:00
parent cf694ef32b
commit 7b3e998cc6

View file

@ -9,22 +9,28 @@ This module does not include a web interface so you need to open
`chrome://tracing/` in a Chrome browser and load the generated file to view the `chrome://tracing/` in a Chrome browser and load the generated file to view the
result. result.
**Note:** You should not use this module until the `ready` event of the app
module is emitted.
```javascript ```javascript
const {contentTracing} = require('electron') const {app, contentTracing} = require('electron')
const options = { app.on('ready', () => {
categoryFilter: '*', const options = {
traceOptions: 'record-until-full,enable-sampling' categoryFilter: '*',
} traceOptions: 'record-until-full,enable-sampling'
}
contentTracing.startRecording(options, () => { contentTracing.startRecording(options, () => {
console.log('Tracing started') console.log('Tracing started')
setTimeout(() => { setTimeout(() => {
contentTracing.stopRecording('', (path) => { contentTracing.stopRecording('', (path) => {
console.log('Tracing data recorded to ' + path) console.log('Tracing data recorded to ' + path)
}) })
}, 5000) }, 5000)
})
}) })
``` ```