1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #532 from MetaMask/logging-fix

Logging fix
This commit is contained in:
kumavis 2016-08-11 20:50:01 -07:00 committed by GitHub
commit 878a01a294
5 changed files with 24 additions and 12 deletions

View File

@ -13,6 +13,7 @@ const extension = require('./lib/extension')
const STORAGE_KEY = 'metamask-config' const STORAGE_KEY = 'metamask-config'
const controller = new MetamaskController({ const controller = new MetamaskController({
// User confirmation callbacks: // User confirmation callbacks:
showUnconfirmedMessage, showUnconfirmedMessage,

View File

@ -3,6 +3,8 @@ const TESTNET_RPC_URL = 'https://morden.infura.io/'
const DEFAULT_RPC_URL = TESTNET_RPC_URL const DEFAULT_RPC_URL = TESTNET_RPC_URL
const CLASSIC_RPC_URL = 'https://mainnet-nf.infura.io/' const CLASSIC_RPC_URL = 'https://mainnet-nf.infura.io/'
global.METAMASK_DEBUG = false
module.exports = { module.exports = {
network: { network: {
default: DEFAULT_RPC_URL, default: DEFAULT_RPC_URL,
@ -11,4 +13,3 @@ module.exports = {
classic: CLASSIC_RPC_URL, classic: CLASSIC_RPC_URL,
}, },
} }

View File

@ -153,8 +153,9 @@ IdentityStore.prototype.getNetwork = function (err) {
this._currentState.network = 'loading' this._currentState.network = 'loading'
return this._didUpdate() return this._didUpdate()
} }
if (global.METAMASK_DEBUG) {
console.log('web3.getNetwork returned ' + network) console.log('web3.getNetwork returned ' + network)
}
this._currentState.network = network this._currentState.network = network
this._didUpdate() this._didUpdate()
}) })
@ -475,7 +476,9 @@ IdentityStore.prototype._restoreFromSeed = function (password, seed, derivedKey)
keyStore.generateNewAddress(derivedKey, 3) keyStore.generateNewAddress(derivedKey, 3)
configManager.setWallet(keyStore.serialize()) configManager.setWallet(keyStore.serialize())
console.log('restored from seed. saved to keystore') if (global.METAMASK_DEBUG) {
console.log('restored from seed. saved to keystore')
}
return keyStore return keyStore
} }

View File

@ -94,7 +94,9 @@ module.exports = class MetamaskController {
function logger (err, request, response) { function logger (err, request, response) {
if (err) return console.error(err) if (err) return console.error(err)
if (!request.isMetamaskInternal) { if (!request.isMetamaskInternal) {
console.log(`RPC (${originDomain}):`, request, '->', response) if (global.METAMASK_DEBUG) {
console.log(`RPC (${originDomain}):`, request, '->', response)
}
if (response.error) { if (response.error) {
console.error('Error in RPC response:\n', response.error) console.error('Error in RPC response:\n', response.error)
} }
@ -218,7 +220,9 @@ module.exports = class MetamaskController {
// Log blocks // Log blocks
processBlock (block) { processBlock (block) {
console.log(`BLOCK CHANGED: #${block.number.toString('hex')} 0x${block.hash.toString('hex')}`) if (global.METAMASK_DEBUG) {
console.log(`BLOCK CHANGED: #${block.number.toString('hex')} 0x${block.hash.toString('hex')}`)
}
this.verifyNetwork() this.verifyNetwork()
} }

View File

@ -1,17 +1,20 @@
const createStore = require('redux').createStore const createStore = require('redux').createStore
const applyMiddleware = require('redux').applyMiddleware const applyMiddleware = require('redux').applyMiddleware
const thunkMiddleware = require('redux-thunk') const thunkMiddleware = require('redux-thunk')
const createLogger = require('redux-logger')
const rootReducer = require('./reducers') const rootReducer = require('./reducers')
const createLogger = require('redux-logger')
global.METAMASK_DEBUG = false
module.exports = configureStore module.exports = configureStore
const loggerMiddleware = createLogger() const loggerMiddleware = createLogger({
predicate: () => global.METAMASK_DEBUG,
})
const createStoreWithMiddleware = applyMiddleware( const middlewares = [thunkMiddleware, loggerMiddleware]
thunkMiddleware,
loggerMiddleware const createStoreWithMiddleware = applyMiddleware(...middlewares)(createStore)
)(createStore)
function configureStore (initialState) { function configureStore (initialState) {
return createStoreWithMiddleware(rootReducer, initialState) return createStoreWithMiddleware(rootReducer, initialState)