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

Add ability to hide logging messages in production.

This commit is contained in:
Kevin Serrano 2016-08-11 13:59:14 -07:00
parent ffb48028a3
commit 9904b4ef5a
4 changed files with 34 additions and 8 deletions

View File

@ -2,6 +2,7 @@ const MAINET_RPC_URL = 'https://mainnet.infura.io/'
const TESTNET_RPC_URL = 'https://morden.infura.io/' 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/'
const DEVELOPMENT_MODE = true
module.exports = { module.exports = {
network: { network: {
@ -10,5 +11,5 @@ module.exports = {
testnet: TESTNET_RPC_URL, testnet: TESTNET_RPC_URL,
classic: CLASSIC_RPC_URL, classic: CLASSIC_RPC_URL,
}, },
developmentMode: DEVELOPMENT_MODE
} }

View File

@ -7,6 +7,7 @@ const HostStore = require('./lib/remote-store.js').HostStore
const Web3 = require('web3') const Web3 = require('web3')
const ConfigManager = require('./lib/config-manager') const ConfigManager = require('./lib/config-manager')
const extension = require('./lib/extension') const extension = require('./lib/extension')
const developmentMode = require('./config').developmentMode
module.exports = class MetamaskController { module.exports = class MetamaskController {
@ -93,7 +94,7 @@ 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 (developmentMode && !request.isMetamaskInternal) {
console.log(`RPC (${originDomain}):`, request, '->', response) 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 +219,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 (developmentMode) {
console.log(`BLOCK CHANGED: #${block.number.toString('hex')} 0x${block.hash.toString('hex')}`)
}
this.verifyNetwork() this.verifyNetwork()
} }

View File

@ -35,6 +35,7 @@
"debounce": "^1.0.0", "debounce": "^1.0.0",
"dnode": "^1.2.2", "dnode": "^1.2.2",
"end-of-stream": "^1.1.0", "end-of-stream": "^1.1.0",
"envify": "^3.4.1",
"eth-bin-to-ops": "^1.0.0", "eth-bin-to-ops": "^1.0.0",
"eth-lightwallet": "^2.3.3", "eth-lightwallet": "^2.3.3",
"eth-query": "^1.0.3", "eth-query": "^1.0.3",

View File

@ -1,18 +1,39 @@
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 developmentMode = require('../../app/scripts/config').developmentMode
module.exports = configureStore module.exports = configureStore
const loggerMiddleware = createLogger() const middlewares = [thunkMiddleware]
const createStoreWithMiddleware = applyMiddleware( console.log(developmentMode)
thunkMiddleware, if (developmentMode) {
loggerMiddleware console.log("Development Mode ON.")
const createLogger = require('redux-logger')
const loggerMiddleware = createLogger()
middlewares.push(loggerMiddleware)
} else {
console.log("Development Mode OFF.")
}
const createStoreWithMiddleware = applyMiddleware(...middlewares
)(createStore) )(createStore)
function configureStore (initialState) { function configureStore (initialState) {
return createStoreWithMiddleware(rootReducer, initialState) return createStoreWithMiddleware(rootReducer, initialState)
} }
// import thunk from 'redux-thunk';
//
// const middlewares = [thunk];
//
// if (process.env.NODE_ENV === `development`) {
// const createLogger = require(`redux-logger`);
// const logger = createLogger();
// middlewares.push(logger);
// }
//
// const store = compose(applyMiddleware(...middlewares))(createStore)(reducer);