2018-06-19 01:45:58 +00:00
|
|
|
'use strict'
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// TODO(deepak1556): Deprecate and remove standalone netLog module,
|
2019-02-14 13:40:24 +00:00
|
|
|
// it is now a property of session module.
|
2018-10-04 18:08:56 +00:00
|
|
|
const { app, session } = require('electron')
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// Fallback to default session.
|
|
|
|
Object.setPrototypeOf(module.exports, new Proxy({}, {
|
|
|
|
get (target, property) {
|
|
|
|
if (!app.isReady()) return
|
|
|
|
|
|
|
|
const netLog = session.defaultSession.netLog
|
2019-03-26 02:40:38 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
if (!Object.getPrototypeOf(netLog).hasOwnProperty(property)) return
|
|
|
|
|
2019-03-26 02:40:38 +00:00
|
|
|
// check for properties on the prototype chain that aren't functions
|
|
|
|
if (typeof netLog[property] !== 'function') return netLog[property]
|
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
// Returning a native function directly would throw error.
|
|
|
|
return (...args) => netLog[property](...args)
|
|
|
|
},
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
ownKeys () {
|
|
|
|
if (!app.isReady()) return []
|
2018-06-19 01:45:58 +00:00
|
|
|
|
2018-10-04 18:08:56 +00:00
|
|
|
return Object.getOwnPropertyNames(Object.getPrototypeOf(session.defaultSession.netLog))
|
|
|
|
},
|
|
|
|
|
|
|
|
getOwnPropertyDescriptor (target) {
|
|
|
|
return { configurable: true, enumerable: true }
|
|
|
|
}
|
|
|
|
}))
|