feat: add --enable-api-filtering-logging commandline switch (#20335)

This commit is contained in:
Milan Burda 2019-10-04 19:49:09 +02:00 committed by Jeremy Apthorp
parent e1eb9519f5
commit ccff140046
15 changed files with 85 additions and 29 deletions

View file

@ -1,12 +1,24 @@
import { nativeImage } from 'electron'
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'
const { hasSwitch } = process.electronBinding('command_line')
// |options.types| can't be empty and must be an array
function isValid (options: Electron.SourcesOptions) {
const types = options ? options.types : undefined
return Array.isArray(types)
}
const enableStacks = hasSwitch('enable-api-filtering-logging')
function getCurrentStack () {
const target = {}
if (enableStacks) {
Error.captureStackTrace(target, getCurrentStack)
}
return (target as any).stack
}
export async function getSources (options: Electron.SourcesOptions) {
if (!isValid(options)) throw new Error('Invalid options')
@ -21,7 +33,7 @@ export async function getSources (options: Electron.SourcesOptions) {
captureScreen,
thumbnailSize,
fetchWindowIcons
} as ElectronInternal.GetSourcesOptions)
} as ElectronInternal.GetSourcesOptions, getCurrentStack())
return sources.map(source => ({
id: source.id,