mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
debug - prefer logger over console
This commit is contained in:
parent
a265144176
commit
96d1175834
@ -1,6 +1,8 @@
|
|||||||
const urlUtil = require('url')
|
const urlUtil = require('url')
|
||||||
const endOfStream = require('end-of-stream')
|
const endOfStream = require('end-of-stream')
|
||||||
const pipe = require('pump')
|
const pipe = require('pump')
|
||||||
|
const log = require('loglevel')
|
||||||
|
const extension = require('extensionizer')
|
||||||
const LocalStorageStore = require('obs-store/lib/localStorage')
|
const LocalStorageStore = require('obs-store/lib/localStorage')
|
||||||
const storeTransform = require('obs-store/lib/transform')
|
const storeTransform = require('obs-store/lib/transform')
|
||||||
const ExtensionPlatform = require('./platforms/extension')
|
const ExtensionPlatform = require('./platforms/extension')
|
||||||
@ -9,13 +11,11 @@ const migrations = require('./migrations/')
|
|||||||
const PortStream = require('./lib/port-stream.js')
|
const PortStream = require('./lib/port-stream.js')
|
||||||
const NotificationManager = require('./lib/notification-manager.js')
|
const NotificationManager = require('./lib/notification-manager.js')
|
||||||
const MetamaskController = require('./metamask-controller')
|
const MetamaskController = require('./metamask-controller')
|
||||||
const extension = require('extensionizer')
|
|
||||||
const firstTimeState = require('./first-time-state')
|
const firstTimeState = require('./first-time-state')
|
||||||
|
|
||||||
const STORAGE_KEY = 'metamask-config'
|
const STORAGE_KEY = 'metamask-config'
|
||||||
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
|
const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG'
|
||||||
|
|
||||||
const log = require('loglevel')
|
|
||||||
window.log = log
|
window.log = log
|
||||||
log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn')
|
log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn')
|
||||||
|
|
||||||
@ -29,12 +29,12 @@ let popupIsOpen = false
|
|||||||
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
|
const diskStore = new LocalStorageStore({ storageKey: STORAGE_KEY })
|
||||||
|
|
||||||
// initialization flow
|
// initialization flow
|
||||||
initialize().catch(console.error)
|
initialize().catch(log.error)
|
||||||
|
|
||||||
async function initialize () {
|
async function initialize () {
|
||||||
const initState = await loadStateFromPersistence()
|
const initState = await loadStateFromPersistence()
|
||||||
await setupController(initState)
|
await setupController(initState)
|
||||||
console.log('MetaMask initialization complete.')
|
log.debug('MetaMask initialization complete.')
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -340,7 +340,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
setupUntrustedCommunication (connectionStream, originDomain) {
|
setupUntrustedCommunication (connectionStream, originDomain) {
|
||||||
// Check if new connection is blacklisted
|
// Check if new connection is blacklisted
|
||||||
if (this.blacklistController.checkForPhishing(originDomain)) {
|
if (this.blacklistController.checkForPhishing(originDomain)) {
|
||||||
console.log('MetaMask - sending phishing warning for', originDomain)
|
log.debug('MetaMask - sending phishing warning for', originDomain)
|
||||||
this.sendPhishingWarning(connectionStream, originDomain)
|
this.sendPhishingWarning(connectionStream, originDomain)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -374,7 +374,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
dnode,
|
dnode,
|
||||||
outStream,
|
outStream,
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) console.error(err)
|
if (err) log.error(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
dnode.on('remote', (remote) => {
|
dnode.on('remote', (remote) => {
|
||||||
@ -402,7 +402,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
providerStream,
|
providerStream,
|
||||||
outStream,
|
outStream,
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) console.error(err)
|
if (err) log.error(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
function loggerMiddleware (req, res, next, end) {
|
function loggerMiddleware (req, res, next, end) {
|
||||||
next((cb) => {
|
next((cb) => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
console.error('Error in RPC response:\n', res)
|
log.error('Error in RPC response:\n', res)
|
||||||
}
|
}
|
||||||
if (req.isMetamaskInternal) return
|
if (req.isMetamaskInternal) return
|
||||||
log.info(`RPC (${originDomain}):`, req, '->', res)
|
log.info(`RPC (${originDomain}):`, req, '->', res)
|
||||||
@ -441,7 +441,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
this.publicConfigStore,
|
this.publicConfigStore,
|
||||||
outStream,
|
outStream,
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) console.error(err)
|
if (err) log.error(err)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user