diff --git a/src/modules/main/logFileProcessor/logFileProcessor.js b/src/modules/main/logFileProcessor/logFileProcessor.js index a2750ec..ef2b834 100644 --- a/src/modules/main/logFileProcessor/logFileProcessor.js +++ b/src/modules/main/logFileProcessor/logFileProcessor.js @@ -1,5 +1,5 @@ import { LightningElement } from 'lwc'; -import { eventsRegexMain } from 'parser/utilVariables'; +import { eventsRegexMain, timeStampRegex } from 'parser/utilVariables'; import { publish } from 'services/pubsub'; // import { publish, MessageContext } from 'lightning/messageService'; @@ -81,10 +81,6 @@ export default class LogFileProcessor extends LightningElement { nofMethodUnits: 0 }; fileDataPartial = []; - // treeNodes = []; - level = 1; - posinset = 1; - maxsize = 100; // @wire(MessageContext) // messageContext; get acceptedFormats() { @@ -137,25 +133,33 @@ export default class LogFileProcessor extends LightningElement { '=>', line ); - this.createCodeUnit(line, value, idx); + this.createCodeUnit(line, value, idx + 1); break; } } } else if (lineEvent === 'CODE_UNIT_FINISHED') { //process codeunit finish logic - this.exitCodeUnit(idx); + try { + this.exitCodeUnit(idx + 1, line); + } catch (err) { + console.error(e); + } } else if (lineEvent === 'METHOD_ENTRY') { const RegexMap = eventsRegexMain.get(lineEvent); for (let [key, value] of RegexMap) { if (key.test(line)) { // console.log(value, "=>", key.test(line), "=>", line); - this.createMethodUnit(line, value, idx); + this.createMethodUnit(line, value, idx + 1); break; } } } else if (lineEvent === 'METHOD_EXIT') { //process methodunit finish logic - this.exitMethodUnit(idx); + try { + this.exitMethodUnit(idx + 1, line); + } catch (e) { + console.error(e); + } } else { this.addLinetoCUorMU(line, lineEvent, idx); } @@ -282,7 +286,7 @@ export default class LogFileProcessor extends LightningElement { if (enteredCondition) { this.isCurUnitCU = true; cu.Id = this.codeUnitsCount++; - + cu.startTime = this.extractTimeStamp(line); this.addCUtoResult(cu); this.codeUnitsStack.push(cu); } @@ -292,9 +296,15 @@ export default class LogFileProcessor extends LightningElement { * get the current CU and update the lineDuration * Update the currentCUIndex and isCurUnitCU */ - exitCodeUnit(idx) { + exitCodeUnit(idx, line) { let CodeUnit = this.currentCU(); + if (CodeUnit === null) { + throw new Error( + 'Oops!! Some code units are not picked by the parser' + ); + } CodeUnit.unitDuration += ' - ' + idx; + CodeUnit.endTime = this.extractTimeStamp(line); this.codeUnitsStack.pop(); } @@ -335,11 +345,18 @@ export default class LogFileProcessor extends LightningElement { this.addMUtoResult(methodUnit); this.methodUnitsStack.push(methodUnit); } + methodUnit.startTime = this.extractTimeStamp(line); } - exitMethodUnit(index) { + exitMethodUnit(index, line) { let methodUnit = this.currentMU(); + if (methodUnit === null) { + throw new Error( + 'Oops!! Some method units are not picked by the parser' + ); + } methodUnit.unitDuration += ' - ' + index; + methodUnit.endTime = this.extractTimeStamp(line); this.methodUnitsStack.pop(); } @@ -376,7 +393,7 @@ export default class LogFileProcessor extends LightningElement { addCUtoResult(codeUnit) { if (this.codeUnitsStack.length !== 0) { - console.log('Entered length condition'); + // console.log('Entered length condition'); let CUTop = this.currentCU(); console.log(CUTop.childUnitsandLines); if ( @@ -385,17 +402,12 @@ export default class LogFileProcessor extends LightningElement { ) { CUTop.childUnitsandLines = []; CUTop.childUnitsandLines.push(codeUnit); - this.level++; - this.posinset = 1; - // this.treeNodes.push(this.createNode(codeUnit)); } else { CUTop.childUnitsandLines.push(codeUnit); - // this.treeNodes.push(this.createNode(codeUnit)); } } else { - console.log('Entered direct push condition'); + // console.log('Entered direct push condition'); this.result.push(codeUnit); - // this.treeNodes.push(this.createNode(codeUnit)); } } @@ -404,23 +416,6 @@ export default class LogFileProcessor extends LightningElement { this.addMUtoResult(lineDetails); } - createNode(codeUnit) { - let Node = { - id: codeUnit.Id, - name: codeUnit.cuName, - type: codeUnit.cuType, - hasError: codeUnit.hasError, - hasChild: false, - isExpanded: false, - isSelected: false, - level: this.level, - posinset: this.posinset, - maxsize: this.maxsize - }; - this.posinset++; - return Node; - } - addToFileDataPartial(line, event, lineNumber) { const temp = { line: line, @@ -443,4 +438,14 @@ export default class LogFileProcessor extends LightningElement { }; publish('logChannel', payload); } + + extractTimeStamp(line) { + const durRaw = line.substring(0, line.indexOf('|')); + const match = durRaw.match(timeStampRegex); + if (match !== null && match.length === 4) { + const timeStamp = parseInt(match[3], 10); + return timeStamp; + } + return null; + } } diff --git a/src/modules/main/logViewer/logViewer.css b/src/modules/main/logViewer/logViewer.css index 7e94af7..db0eebb 100644 --- a/src/modules/main/logViewer/logViewer.css +++ b/src/modules/main/logViewer/logViewer.css @@ -344,6 +344,7 @@ th { } .line-text { + line-height: normal; color: #16315a; fill: #16315a; font-weight: 400; diff --git a/src/modules/parser/callTree/callTree.js b/src/modules/parser/callTree/callTree.js index fbb3300..6f45859 100644 --- a/src/modules/parser/callTree/callTree.js +++ b/src/modules/parser/callTree/callTree.js @@ -66,7 +66,7 @@ export function parseResultToTree(result) { // posMap.forEach((value, key) => { // console.log(`Level: ${key}, Position: ${value}`); // }); - // console.log('units', units); + console.log('units', units); return units; } @@ -127,6 +127,7 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) { if (obj.cuType) { // Extract code unit information let duration = 0; + let timeInMS = 0; let uniqueId = null; try { ({ duration, uniqueId } = calculateDuration(obj.unitDuration)); @@ -134,11 +135,18 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) { uniqueId = Math.random().toString(36).substring(2, 6); console.error(e); } + if (obj.startTime && obj.endTime && obj.startTime !== obj.endTime) { + let temp = (obj.endTime - obj.startTime) / 1000000; + timeInMS = temp.toFixed(3); + } else { + timeInMS = 'N/A'; + } const unit = { id: uniqueId, parentId: parentId, type: obj.cuType, name: obj.cuName, + timeInMS: timeInMS, level: level, unitDuration: obj.unitDuration, unitLength: duration, @@ -153,6 +161,13 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) { // Extract code unit information let duration = 0; let uniqueId = null; + let timeInMS = 0; + if (obj.startTime && obj.endTime && obj.startTime !== obj.endTime) { + let temp = (obj.endTime - obj.startTime) / 1000000; + timeInMS = temp.toFixed(3); + } else { + timeInMS = 'N/A'; + } try { ({ duration, uniqueId } = calculateDuration(obj.unitDuration)); } catch (e) { @@ -163,6 +178,7 @@ function parseDebugLogUnits(obj, units = [], level = 1, parentId) { id: uniqueId, parentId: parentId, name: obj.methodTitle, + timeInMS: timeInMS, type: obj.type, level: level, unitDuration: obj.unitDuration, diff --git a/src/modules/parser/utilVariables/utilVariables.js b/src/modules/parser/utilVariables/utilVariables.js index a5868bf..259a2a0 100644 --- a/src/modules/parser/utilVariables/utilVariables.js +++ b/src/modules/parser/utilVariables/utilVariables.js @@ -83,3 +83,7 @@ eventsRegexMain.set( ] ]) ); + +export let timeStampRegex = new RegExp( + '(\\d{2}:\\d{2}:\\d{2})\\.(\\d+)\\s\\((\\d+)\\)' +); diff --git a/src/modules/ui/utilityPanel/utilityPanel.html b/src/modules/ui/utilityPanel/utilityPanel.html index 4d30691..9cb9d6f 100644 --- a/src/modules/ui/utilityPanel/utilityPanel.html +++ b/src/modules/ui/utilityPanel/utilityPanel.html @@ -140,6 +140,38 @@