From 8aca5bf4b5cdfc398f250040673b2c174c51167c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 20 Feb 2017 12:59:44 -0800 Subject: [PATCH 1/2] Add debug logging to ui routing logic. --- .eslintrc | 1 + mock-dev.js | 2 ++ package.json | 1 + ui-dev.js | 4 ++++ ui/app/app.js | 20 ++++++++++++++++++++ ui/index.js | 3 +++ 6 files changed, 31 insertions(+) diff --git a/.eslintrc b/.eslintrc index 17a59d22d..8bbfe13c7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,6 +25,7 @@ "globals": { "document": false, + "log": true, "navigator": false, "web3": true, "window": false diff --git a/mock-dev.js b/mock-dev.js index 6563964c3..9025faf49 100644 --- a/mock-dev.js +++ b/mock-dev.js @@ -26,6 +26,8 @@ const firstTimeState = require('./app/scripts/first-time-state') const extension = require('./development/mockExtension') const noop = function () {} +const log = require('loglevel') +window.log = log // // Query String diff --git a/package.json b/package.json index 11cb353ea..d48e77932 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "iframe-stream": "^1.0.2", "inject-css": "^0.1.1", "jazzicon": "^1.2.0", + "loglevel": "^1.4.1", "menu-droppo": "^1.1.0", "metamask-logo": "^2.1.2", "mississippi": "^1.2.0", diff --git a/ui-dev.js b/ui-dev.js index e39340859..dbcc0dca7 100644 --- a/ui-dev.js +++ b/ui-dev.js @@ -22,6 +22,10 @@ const configureStore = require('./development/uiStore') const states = require('./development/states') const Selector = require('./development/selector') +// logger +const log = require('loglevel') +window.log = log + // Query String const qs = require('qs') let queryString = qs.parse(window.location.href.split('#')[1]) diff --git a/ui/app/app.js b/ui/app/app.js index ea755bec5..f3581b56d 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -351,12 +351,14 @@ App.prototype.renderPrimary = function () { // notices if (!props.noActiveNotices && !global.METAMASK_DEBUG) { + log.debug('rendering notice screen for unread notices.') return h(NoticeScreen, { notice: props.lastUnreadNotice, key: 'NoticeScreen', onConfirm: () => props.dispatch(actions.markNoticeRead(props.lastUnreadNotice)), }) } else if (props.lostAccounts && props.lostAccounts.length > 0) { + log.debug('rendering notice screen for lost accounts view.') return h(NoticeScreen, { notice: generateLostAccountsNotice(props.lostAccounts), key: 'LostAccountsNotice', @@ -365,18 +367,22 @@ App.prototype.renderPrimary = function () { } if (props.seedWords) { + log.debug('rendering seed words') return h(HDCreateVaultComplete, {key: 'HDCreateVaultComplete'}) } // show initialize screen if (!props.isInitialized || props.forgottenPassword) { // show current view + log.debug('rendering an initialize screen') switch (props.currentView.name) { case 'restoreVault': + log.debug('rendering restore vault screen') return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'}) default: + log.debug('rendering menu screen') return h(InitializeMenuScreen, {key: 'menuScreenInit'}) } } @@ -386,9 +392,11 @@ App.prototype.renderPrimary = function () { switch (props.currentView.name) { case 'restoreVault': + log.debug('rendering restore vault screen') return h(HDRestoreVaultScreen, {key: 'HDRestoreVaultScreen'}) default: + log.debug('rendering locked screen') return h(UnlockScreen, {key: 'locked'}) } } @@ -397,36 +405,47 @@ App.prototype.renderPrimary = function () { switch (props.currentView.name) { case 'accounts': + log.debug('rendering accounts screen') return h(AccountsScreen, {key: 'accounts'}) case 'accountDetail': + log.debug('rendering account detail screen') return h(AccountDetailScreen, {key: 'account-detail'}) case 'sendTransaction': + log.debug('rendering send tx screen') return h(SendTransactionScreen, {key: 'send-transaction'}) case 'newKeychain': + log.debug('rendering new keychain screen') return h(NewKeyChainScreen, {key: 'new-keychain'}) case 'confTx': + log.debug('rendering confirm tx screen') return h(ConfirmTxScreen, {key: 'confirm-tx'}) case 'config': + log.debug('rendering config screen') return h(ConfigScreen, {key: 'config'}) case 'import-menu': + log.debug('rendering import screen') return h(Import, {key: 'import-menu'}) case 'reveal-seed-conf': + log.debug('rendering reveal seed confirmation screen') return h(RevealSeedConfirmation, {key: 'reveal-seed-conf'}) case 'info': + log.debug('rendering info screen') return h(InfoScreen, {key: 'info'}) case 'buyEth': + log.debug('rendering buy ether screen') return h(BuyView, {key: 'buyEthView'}) case 'qr': + log.debug('rendering show qr screen') return h('div', { style: { position: 'absolute', @@ -454,6 +473,7 @@ App.prototype.renderPrimary = function () { ]) default: + log.debug('rendering default, account detail screen') return h(AccountDetailScreen, {key: 'account-detail'}) } } diff --git a/ui/index.js b/ui/index.js index 8855064f6..36de88c0d 100644 --- a/ui/index.js +++ b/ui/index.js @@ -6,6 +6,9 @@ const configureStore = require('./app/store') const txHelper = require('./lib/tx-helper') module.exports = launchApp +const log = require('loglevel') +window.log = log + function launchApp (opts) { var accountManager = opts.accountManager actions._setBackgroundConnection(accountManager) From b2c68c9ea30a2842892ae0e03a5815d634a74357 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 20 Feb 2017 14:30:58 -0800 Subject: [PATCH 2/2] Set default log levels --- mock-dev.js | 1 + ui-dev.js | 1 + ui/index.js | 1 + 3 files changed, 3 insertions(+) diff --git a/mock-dev.js b/mock-dev.js index 9025faf49..d316aeeba 100644 --- a/mock-dev.js +++ b/mock-dev.js @@ -28,6 +28,7 @@ const noop = function () {} const log = require('loglevel') window.log = log +log.setLevel('info') // // Query String diff --git a/ui-dev.js b/ui-dev.js index dbcc0dca7..0a66a2e8b 100644 --- a/ui-dev.js +++ b/ui-dev.js @@ -25,6 +25,7 @@ const Selector = require('./development/selector') // logger const log = require('loglevel') window.log = log +log.setLevel('info') // Query String const qs = require('qs') diff --git a/ui/index.js b/ui/index.js index 36de88c0d..844e6c417 100644 --- a/ui/index.js +++ b/ui/index.js @@ -8,6 +8,7 @@ module.exports = launchApp const log = require('loglevel') window.log = log +log.setLevel('warn') function launchApp (opts) { var accountManager = opts.accountManager