Skip to content

Commit 12d09d8

Browse files
committed
add control file for console log
1 parent fe950db commit 12d09d8

7 files changed

Lines changed: 34 additions & 25 deletions

File tree

src/app/debugger/debugger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var Ethdebugger = require('chainsql-remix-debug').EthDebugger
44
var remixLib = require('chainsql-remix-lib')
55
var executionContext = require('../../execution-context')
66
var globlalRegistry = require('../../global/registry')
7+
const debLog = require('../../lib/debuglogger')
78

89
/**
910
* Manage remix and source highlighting
@@ -57,7 +58,7 @@ function Debugger (container, sourceHighlighter, localRegistry) {
5758

5859
executionContext.event.register('contextChanged', this, function (context) {
5960
// self.switchProvider(context)
60-
console.log('comment temporary --LC')
61+
debLog('comment temporary --LC')
6162
})
6263

6364
this.debugger.event.register('newTraceLoaded', this, function () {

src/app/execution/txLogger.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var executionContext = require('../../execution-context')
1414
var modalDialog = require('../ui/modal-dialog-custom')
1515
var typeConversion = remixLib.execution.typeConversion
1616
var globlalRegistry = require('../../global/registry')
17+
const debLog = require('../../lib/debuglogger')
1718

1819
var css = csjs`
1920
.log {
@@ -148,7 +149,7 @@ class TxLogger {
148149

149150
this.logKnownTX = this._deps.editorPanel.registerCommand('knownTransaction', (args, cmds, append) => {
150151
var data = args[0]
151-
console.log('[logKnowTX]:', data)
152+
debLog('[txLogger-logKnowTX]:', data)
152153
var el
153154
if (data.tx.isCall) {
154155
el = renderCall(this, data)
@@ -375,7 +376,7 @@ module.exports = TxLogger
375376
// helpers
376377

377378
function txDetails (e, tx, data, obj) {
378-
console.log(tx)
379+
debLog('txLogger-txDetails tx:', tx)
379380
var table = document.querySelector(`#${tx.id} [class^="txTable"]`)
380381
var from = obj.from
381382
var to = obj.to

src/app/tabs/run-tab.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var addTooltip = require('../ui/tooltip')
1818
var css = require('./styles/run-tab-styles')
1919
var MultiParamManager = require('../../multiParamManager')
2020
var modalDialog = require('../ui/modaldialog')
21+
const debLog = require('../../lib/debuglogger')
2122

2223
function runTab (opts, localRegistry) {
2324
/* -------------------------
@@ -153,17 +154,13 @@ function fillAccountsList (container, self) {
153154
if (err) { addTooltip(`Cannot get account list: ${err}`) }
154155

155156
for (var loadedaddress in loadedAccounts) {
156-
//console.log(loadedaddress)
157157
if (accounts.indexOf(loadedaddress) === -1) {
158-
//console.log('need rmove')
159158
txOrigin.removeChild(txOrigin.querySelector('option[value="' + loadedaddress + '"]'))
160159
delete loadedAccounts[loadedaddress]
161160
}
162161
}
163-
//console.log('begin to add addr')
164162
for (var i in accounts) {
165163
var address = accounts[i]
166-
//console.log(address)
167164
if (!loadedAccounts[address]) {
168165
txOrigin.appendChild(yo`<option value="${address}" >${address}</option>`)
169166
loadedAccounts[address] = 1
@@ -375,7 +372,7 @@ function contractDropdown (events, self) {
375372
self._deps.logCallback(`creation of ${selectedContract.name} pending...`)
376373
executionContext.initContractObj(false, selectedContract.name, selectedContract.contract.object.abi)
377374
self._deps.udapp.createContract(data, (error, txResult) => {
378-
console.log(txResult)
375+
debLog('createContract ret:',txResult)
379376
if (!error) {
380377
var isVM = executionContext.isVM()
381378
if (isVM) {
@@ -414,7 +411,7 @@ function contractDropdown (events, self) {
414411
self._deps.filePanel.compilerMetadata().metadataOf(selectedContract.name, (error, contractMetadata) => {
415412
if (error) return self._deps.logCallback(`creation of ${selectedContract.name} errored: ` + error)
416413
if (!contractMetadata || (contractMetadata && contractMetadata.autoDeployLib)) {
417-
console.log('autoDeployLib')
414+
debLog('autoDeployLib, args:', args)
418415
txFormat.buildData(selectedContract.name, selectedContract.contract.object, self._deps.compiler.getContracts(), true, constructor, args, (error, data) => {
419416
createInstanceCallback(error, selectedContract, data)
420417
}, (msg) => {
@@ -426,7 +423,7 @@ function contractDropdown (events, self) {
426423
self._deps.udapp.runTx(data, runTxCallback)
427424
})
428425
} else {
429-
console.log('no-autoDeployLib')
426+
debLog('no-autoDeployLib')
430427
if (Object.keys(selectedContract.contract.object.evm.bytecode.linkReferences).length) self._deps.logCallback(`linking ${JSON.stringify(selectedContract.contract.object.evm.bytecode.linkReferences, null, '\t')} using ${JSON.stringify(contractMetadata.linkReferences, null, '\t')}`)
431428
txFormat.encodeConstructorCallAndLinkLibraries(selectedContract.contract.object, args, constructor, contractMetadata.linkReferences, selectedContract.contract.object.evm.bytecode.linkReferences, (error, data) => {
432429
if (data) data.contractName = selectedContract.name
@@ -620,9 +617,9 @@ function settings (container, self) {
620617
})
621618

622619
selectExEnv.addEventListener('change', function (event) {
623-
console.log('environment changed llc')
620+
debLog('environment changed llc')
624621
let context = selectExEnv.options[selectExEnv.selectedIndex].value
625-
console.log('context:' + context)
622+
debLog('context:' + context)
626623
executionContext.executionContextChange(context, null, () => {
627624
modalDialogCustom.confirm(null, 'Are you sure you want to connect to a ChainSQL node?', () => {
628625
modalDialogCustom.prompt(null, 'ChainSQL Websocket Address', 'ws://localhost:5215', (target) => {

src/lib/debuglogger.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict'
2+
3+
function disableDebugLog(){
4+
return;
5+
}
6+
var enableDebugLog = console.log
7+
8+
const env = {
9+
devEnv : enableDebugLog,
10+
productEnv : disableDebugLog
11+
}
12+
module.exports = env.productEnv

src/multiParamManager.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var css = require('./universal-dapp-styles')
55
var copyToClipboard = require('./app/ui/copy-to-clipboard')
66
var remixLib = require('chainsql-remix-lib')
77
var txFormat = remixLib.execution.txFormat
8+
const debLog = require('./lib/debuglogger')
89

910
class MultiParamManager {
1011

@@ -121,6 +122,7 @@ class MultiParamManager {
121122
this.basicInputField.setAttribute('title', this.inputs)
122123

123124
var onClick = (domEl) => {
125+
debLog("[In onClick], this.basicInputField.value:", this.basicInputField.value)
124126
this.clickCallBack(this.funABI.inputs, this.basicInputField.value)
125127
}
126128

@@ -132,6 +134,7 @@ class MultiParamManager {
132134

133135
var multiOnClick = () => {
134136
var valsString = this.getMultiValsString()
137+
debLog("[In multiOnClick], valsString:", valsString)
135138
if (valsString) {
136139
this.clickCallBack(this.funABI.inputs, valsString)
137140
} else {

src/recorder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var format = remixLib.execution.txFormat
66
var txHelper = remixLib.execution.txHelper
77
var async = require('async')
88
var modal = require('./app/ui/modal-dialog-custom')
9+
const debLog = require('./lib/debuglogger')
910

1011
/**
1112
* Record transaction as long as the user create them.
@@ -65,7 +66,7 @@ class Recorder {
6566
})
6667

6768
udapp.event.register('transactionExecuted', (error, from, to, data, call, txResult, timestamp) => {
68-
console.log(txResult)
69+
debLog('recorder-transactionExecuted-callback, txResult:', txResult)
6970
if (error) return console.log(error)
7071
if (call) return
7172

src/universal-dapp.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var globalRegistry = require('./global/registry')
2020
var modalDialog = require('./app/ui/modaldialog')
2121
var typeConversion = remixLib.execution.typeConversion
2222
var confirmDialog = require('./app/execution/confirmDialog')
23+
const debLog = require('./lib/debuglogger')
2324

2425
function UniversalDApp (opts, localRegistry) {
2526
this.event = new EventManager()
@@ -168,7 +169,6 @@ UniversalDApp.prototype.getBalance = function (address, cb) {
168169
return cb('No accounts?')
169170
}
170171
if(executionContext.chainsql().api.isConnected()) {
171-
console.log(address)
172172
executionContext.chainsql().api.getBalances(address).then(balanceObj => {
173173
for(let item of balanceObj) {
174174
if(item.currency === "ZXC") {
@@ -241,8 +241,8 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
241241
}
242242
}
243243
// contractsDetails is used to resolve libraries
244-
245-
console.log(value)
244+
debLog('function call args:', args)
245+
debLog('function call params:', value)
246246
txFormat.buildData(args.contractName, args.contractAbi, self.data.contractsDetails, false, args.funABI, value, (error, data) => {
247247
if (!error) {
248248
if (isUserAction) {
@@ -253,8 +253,7 @@ UniversalDApp.prototype.call = function (isUserAction, args, value, lookupOnly,
253253
}
254254
}
255255
self.callFunction(args.address, data, args.funABI, (error, txResult) => {
256-
console.log(error)
257-
console.log(txResult)
256+
debLog('function call ret:', txResult)
258257
if (!error) {
259258
var isVM = executionContext.isVM()
260259
if (isVM) {
@@ -313,9 +312,6 @@ UniversalDApp.prototype.createContract = function (data, callback) {
313312
* @param {Function} callback - callback.
314313
*/
315314
UniversalDApp.prototype.callFunction = function (to, data, funAbi, callback) {
316-
// console.log(funAbi)
317-
// console.log(data)
318-
// let funAbiName = funAbi.name + "(" + data.params + ")";
319315
data.funAbi = funAbi
320316
this.runTx({to: to, data: data, useCall: funAbi.constant, isDeploy: false}, (error, txResult) => {
321317
// see universaldapp.js line 660 => 700 to check possible values of txResult (error case)
@@ -376,7 +372,6 @@ UniversalDApp.prototype.runTx = function (args, cb) {
376372
return next(null, 0, gasLimit)
377373
}
378374
self.transactionContextAPI.getValue(function (err, value) {
379-
console.log(err)
380375
next(err, value, gasLimit)
381376
})
382377
},
@@ -399,8 +394,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
399394
if (executionContext.isVM() && !self.accounts[address]) {
400395
return next('Invalid account selected')
401396
}
402-
console.log(address)
403-
console.log(self.chainsqlAccounts)
397+
debLog('all Accounts:', self.chainsqlAccounts)
404398
executionContext.chainsql().as(self.chainsqlAccounts[address])
405399
next(null, address, value, gasLimit)
406400
})
@@ -495,7 +489,7 @@ UniversalDApp.prototype.runTx = function (args, cb) {
495489
},
496490
function (error, result) {
497491
let eventName = (tx.useCall ? 'callExecuted' : 'transactionExecuted')
498-
console.log('[In runTransaction], origin tx:', tx)
492+
debLog('[In runTransaction], origin tx:', tx)
499493
self.event.trigger(eventName, [error, tx.from, tx.to, tx.data, tx.useCall, result, timestamp, payLoad])
500494

501495
if (error && (typeof (error) !== 'string')) {

0 commit comments

Comments
 (0)