From 3bb28f6e25aff1efc233b057c77767e76a93c472 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Nov 2019 13:47:39 -0500 Subject: [PATCH] add mappings to better identify what objects individual logs correpond to --- package.json | 1 + src/App.js | 2 +- src/DataManager.js | 71 ++++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 5 ++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ffb314..b6a9bd7 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "bootstrap": "^4.3.1", "fs-extra": "^8.1.0", "jquery": "^3.4.1", + "lodash.get": "^4.4.2", "n-readlines": "^1.0.0", "react": "^16.11.0", "react-bootstrap": "^1.0.0-beta.14", diff --git a/src/App.js b/src/App.js index 4016fbf..462568e 100644 --- a/src/App.js +++ b/src/App.js @@ -35,7 +35,7 @@ class App extends React.PureComponent { { name: 'parent', title: 'ParentName'}, { name: 'summary', title: 'Log', width: 600, hidden: true }, { name: 'type', title: 'Type' }, - { name: 'name', title: 'Name', width: 350}, + { name: 'name', title: 'Name', width: 450}, { name: 'inputs_preview', title: 'Inputs'}, { name: 'outputs_preview', title: 'Outputs'}, { name: 'timestamp', title: 'Timestamp', hidden: true }, diff --git a/src/DataManager.js b/src/DataManager.js index 69183a4..63df645 100644 --- a/src/DataManager.js +++ b/src/DataManager.js @@ -1,3 +1,52 @@ +var _get = require('lodash.get'); + +// map a property depending on type to an identifier +const identifier_mappings = { + request: { + "pipeline:register": "inputs[0].file", + "processes:register": "inputs[0]", + "services:register": "inputs[0]", + "process:logs:register": "inputs[0].processName", + "runcode:whitelist": "inputs[0]", + "runcode:register": "inputs[0]", + "communication:node:register": "inputs[0]", + "blockchain:node:register": "inputs[0]", + "blockchain:node:start": "inputs[0].client", + "whisper:node:register": "inputs[0]", + "blockchain:client:register": "inputs[0]", + "blockchain:api:register": "inputs[1]", + "deployment:deployer:register": "inputs[0]", + "blockchain:client:provider": "inputs[0]", + "embarkjs:plugin:register": "inputs", // multiple relevant params + "embarkjs:console:register": "inputs", // multiple relevant params + "embarkjs:contract:generate": "inputs[0].className", // multiple relevant params + "console:register:helpCmd": "inputs[0].cmdName", + "storage:node:register": "inputs[0]", + "storage:upload:register": "inputs[0]", + "deployment:contract:deploy": "inputs[0].className", + }, + trigger_action: { + "deployment:contract:shouldDeploy": "inputs.contract.className", + "deployment:contract:beforeDeploy": "inputs.contract.className", + "deployment:contract:deployed": "inputs.contract.className", + "deployment:contract:undeployed": "inputs.contract.className", + "blockchain:proxy:request": "inputs.reqData.method", + "blockchain:proxy:response": "inputs.reqData.method", + }, + action_run: { + "deployment:contract:shouldDeploy": "inputs.contract.className", + "deployment:contract:beforeDeploy": "inputs.contract.className", + "deployment:contract:deployed": "inputs.contract.className", + "deployment:contract:undeployed": "inputs.contract.className", + "blockchain:proxy:request": "inputs.reqData.method", + "blockchain:proxy:response": "inputs.reqData.method", + }, + method: { + "deployContract": "inputs.contract.className" + } +} + +identifier_mappings.old_request = identifier_mappings.request; class LogManager { @@ -15,6 +64,10 @@ class LogManager { let session = Object.values(data).find((x) => x.session === x.id) return Object.values(data).sort((x) => x.timestamp).map((x) => { + // TODO: should be done on the embark level not on the logger + if (x.name && x.name.indexOf('bound ') > 0) { + x.name = x.name.replace('bound ', ' ') + } x.timepassed = (x.timestamp - session.timestamp) / 1000.0; if (data[x.parent_id]) { if (x.parent_id === session.id && x.module) { @@ -24,6 +77,24 @@ class LogManager { } } + if (identifier_mappings[x.type] && identifier_mappings[x.type][x.name]) { + x.name += ` (${_get(x, identifier_mappings[x.type][x.name], "???")})` + } else if (x.type === 'action_run') { + let real_name = x.name.split(" ")[0]; + + if (identifier_mappings[x.type] && identifier_mappings[x.type][real_name]) { + x.name += ` (${_get(x, identifier_mappings[x.type][real_name], "???")})` + } + } + + if (x.name === "blockchain:proxy:request") { + if (x && x.inputs && x.inputs.reqData && x.inputs.reqData.method) { + x.name += ` (${x.inputs.reqData.method})` + } else { + x.name += ` (???)` + } + } + if (x.inputs) { let params = [] if (Array.isArray(x.inputs)) { diff --git a/yarn.lock b/yarn.lock index 2a81c36..be85cc1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6105,6 +6105,11 @@ lodash.flow@^3.3.0: resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a" integrity sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o= +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= + lodash.memoize@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"