Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logerrors #8

Merged
merged 3 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions src/modules/main/logFileProcessor/logFileProcessor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { LightningElement } from 'lwc';
import { eventsRegexMain, timeStampRegex } from 'parser/utilVariables';
import {
eventsRegexMain,
timeStampRegex,
fatalErrRegex,
expThrownRegex
} from 'parser/utilVariables';

import { publish } from 'services/pubsub';
// import { publish, MessageContext } from 'lightning/messageService';
Expand Down Expand Up @@ -65,6 +70,7 @@ export default class LogFileProcessor extends LightningElement {
STD_EXP_MATCHER = new RegExp('^[0-9:.]*\\s\\([0-9]*\\)(|)[A-Z_]*.*');
EXE_ANONYMOUS_MATCHER = new RegExp('^(Execute\\sAnonymous:\\s).*');
result = [];
errors = [];
isCurUnitCU = true;
codeUnitsStack = [];
methodUnitsStack = [];
Expand All @@ -78,7 +84,8 @@ export default class LogFileProcessor extends LightningElement {
fileName: '',
nofLines: 0,
nofCodeUnits: 0,
nofMethodUnits: 0
nofMethodUnits: 0,
errors: []
};
fileDataPartial = [];
// @wire(MessageContext)
Expand All @@ -94,17 +101,12 @@ export default class LogFileProcessor extends LightningElement {
console.log('[fileUploader.js] File Size: ', rawFile.size);
reader.onload = (e) => {
const file = e.target.result;
// console.log(file);
// console.log(file);
this.fileData = file.split(/\r\n|\n/);

console.log(
'[fileUploader.js] No.of Lines: ',
this.fileData.length
);
// lines.forEach((line) => {
// console.log("Single Line: ", line);
// });
this.processLogData();
};
reader.onerror = (e) => {
Expand Down Expand Up @@ -161,6 +163,27 @@ export default class LogFileProcessor extends LightningElement {
console.error(e);
}
} else {
if (lineEvent === 'EXCEPTION_THROWN') {
if (expThrownRegex.test(line)) {
let errStr = line.split('|').pop().trim();
this.createErrorObject(
idx + 1,
'EXCEPTION_THROWN',
errStr
);
console.log('Exception Thrown: ', errStr);
}
} else if (lineEvent === 'FATAL_ERROR') {
if (fatalErrRegex.test(line)) {
let errStr = line.split('|').pop().trim();
console.log('Fatal Error: ', errStr);
this.createErrorObject(
idx + 1,
'FATAL_ERROR',
errStr
);
}
}
this.addLinetoCUorMU(line, lineEvent, idx);
}

Expand Down Expand Up @@ -429,6 +452,7 @@ export default class LogFileProcessor extends LightningElement {
this.fileMetadata.nofCodeUnits = this.codeUnitsCount;
this.fileMetadata.nofMethodUnits = this.methodUnitsCount;
this.fileMetadata.nofLines = this.fileData.length;
this.fileMetadata.errors = this.errors;
// console.log("Event Picklist Values: ", this.eventsPicklistValues);
const payload = {
fileMetadata: this.fileMetadata,
Expand All @@ -448,4 +472,16 @@ export default class LogFileProcessor extends LightningElement {
}
return null;
}

createErrorObject(line, event, errMsg) {
let idx = this.errors.length + 1;
const errObj = {
id: idx,
line: line,
errEvent: event,
message: errMsg
};
this.errors.push(errObj);
// console.log('Error Object: ', errObj);
}
}
21 changes: 12 additions & 9 deletions src/modules/main/logViewer/logViewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ a {
overflow: visible;
z-index: 10;
}
.log-errors {
margin-right: auto;
color: #ba0517;
}

.log-errors-no-err-text {
color: #396547;
}

.log-errors-text {
color: #ba0517;
}

.search-res {
background-color: rgb(250, 255, 189);
Expand Down Expand Up @@ -324,10 +336,6 @@ th {
border-color: #76716b;
}

.utility-bar {
flex-direction: row-reverse;
}

.utility-bar-span-text {
align-self: center;
font-size: 0.9rem;
Expand Down Expand Up @@ -417,8 +425,3 @@ th {
.dashboard-widget {
background-color: white;
}

.call-stack {
order: 1;
margin-right: auto;
}
75 changes: 59 additions & 16 deletions src/modules/main/logViewer/logViewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -780,22 +780,61 @@ <h1>
><span class="slds-utility-bar__text">Call Stack</span>
</button>
</li>
<li class="slds-utility-bar__item log-errors">
<template lwc:if={hasErrors}>
<button
class="slds-button slds-utility-bar__action .slds-theme_error error-btn"
onclick={handleErrorClick}
>
<svg
class="slds-button__icon slds-button__icon_left log-errors-text"
aria-hidden="true"
>
<use
xlink:href="/public/assets/icons/utility-sprite/svg/symbols.svg#error"
></use></svg
><span
class="slds-utility-bar__text log-errors-text"
>{errCount} Errors</span
>
</button>
</template>
<template lwc:else>
<button class="slds-button slds-utility-bar__action">
<svg
class="slds-button__icon slds-button__icon_left log-errors-no-err-text"
aria-hidden="true"
>
<use
xlink:href="/public/assets/icons/utility-sprite/svg/symbols.svg#check"
></use></svg
><span
class="slds-utility-bar__text log-errors-no-err-text"
>0 Errors</span
>
</button>
</template>
</li>
<li
class="slds-utility-bar__item utility-bar-span-text slds-var-p-horizontal_xxx-small"
>
<span>Page</span>
</li>
<li
class="slds-utility-bar__item slds-var-p-horizontal_xxx-small utility-bar-input"
>
<input
type="text"
value={linesPerPage}
class={linesPerPageClass}
maxlength="4"
value={pageNumber}
class={pageNumberClass}
inputmode="decimal"
oninput={onLinesPerPageChange}
oninput={onPageNumberChange}
/>
</li>
<li
class="slds-utility-bar__item slds-var-p-horizontal_xxx-small utility-bar-span-text"
class="slds-utility-bar__item utility-bar-span-text slds-var-p-horizontal_xxx-small"
>
<span>Lines per page:</span>
<span>of <strong>{noOfPages}</strong></span>
</li>
<li
class="slds-utility-bar__item slds-var-p-horizontal_xxx-small"
Expand Down Expand Up @@ -828,26 +867,22 @@ <h1>
</div>
</li>
<li
class="slds-utility-bar__item utility-bar-span-text slds-var-p-horizontal_xxx-small"
class="slds-utility-bar__item slds-var-p-horizontal_xxx-small utility-bar-span-text"
>
<span>of <strong>{noOfPages}</strong></span>
<span>Lines per page:</span>
</li>
<li
class="slds-utility-bar__item slds-var-p-horizontal_xxx-small utility-bar-input"
>
<input
type="text"
value={pageNumber}
class={pageNumberClass}
value={linesPerPage}
class={linesPerPageClass}
maxlength="4"
inputmode="decimal"
oninput={onPageNumberChange}
oninput={onLinesPerPageChange}
/>
</li>
<li
class="slds-utility-bar__item utility-bar-span-text slds-var-p-horizontal_xxx-small"
>
<span>Page</span>
</li>
</ul>
<!-- utility panel -->
<template lwc:if={callStackToggle}>
Expand All @@ -857,6 +892,14 @@ <h1>
data={result}
></ui-utility-panel>
</template>
<!-- log errors -->
</footer>
</div>
<ui-log-errors
position-x={errorCenterX}
is-open={errorPopoverOpen}
onclose={closeErrorPopover}
ongotoline={goToErrLine}
errors={errors}
></ui-log-errors>
</template>
53 changes: 52 additions & 1 deletion src/modules/main/logViewer/logViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { LightningElement, track } from 'lwc';
import { subscribe } from 'services/pubsub';

export default class logViewer extends LightningElement {
errorCenterX = 0;
errors = [];
errorPopoverOpen = false;
goToPlaceholder = 'Go to line';
goTohasLabel = false;
reRenderVal = false;
Expand Down Expand Up @@ -129,8 +132,11 @@ export default class logViewer extends LightningElement {
);
this.calculations();
}
if (data.fileMetadata)
if (data.fileMetadata) {
this.fileMetadata = data.fileMetadata;
this.errors = data.fileMetadata.errors;
}

if (data.result) {
// console.log('Result: ', data.result);
this.result = data.result;
Expand All @@ -156,6 +162,10 @@ export default class logViewer extends LightningElement {
: false;
}

get errCount() {
return this.errors.length;
}

renderedCallback() {
const popover = this.template.querySelector('section');

Expand Down Expand Up @@ -561,4 +571,45 @@ export default class logViewer extends LightningElement {
const lNum = event.detail;
this.goToPage(lNum);
}

handleErrorClick() {
this.errorPopoverOpen = !this.errorPopoverOpen;
const button = this.template.querySelector('.error-btn');
const { horizontal, vertical } = this.getWidgetPadding();
// console.log('button', button);
const rect = button.getBoundingClientRect();
// console.log('horizontal', horizontal);
this.errorCenterX = (rect.left + rect.right) / 2 - 24;
// console.log('centerX', this.errorCenterX);
}

closeErrorPopover() {
this.errorPopoverOpen = false;
}

getWidgetPadding() {
const element = this.template.querySelector('.widget');
const rect = element.getBoundingClientRect();
// console.log('rect', rect);
// Calculate content width/height
const contentWidth = element.clientWidth;
const contentHeight = element.clientHeight;

// Calculate padding
const horizontalPadding = rect.width - contentWidth;
const verticalPadding = rect.height - contentHeight;

return {
horizontal: horizontalPadding,
vertical: verticalPadding
};
}

get hasErrors() {
return this.errors.length > 0;
}
goToErrLine(event) {
// console.log('line', event.detail);
this.goToPage(event.detail);
}
}
1 change: 0 additions & 1 deletion src/modules/my/appNavigation/appNavigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
>
<a
class="slds-context-bar__label-action"
href="#"
onclick={handleNavigationItemClick}
data-navitem={itemidx}
title={item.label}
Expand Down
7 changes: 7 additions & 0 deletions src/modules/parser/utilVariables/utilVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,10 @@ eventsRegexMain.set(
export let timeStampRegex = new RegExp(
'(\\d{2}:\\d{2}:\\d{2})\\.(\\d+)\\s\\((\\d+)\\)'
);

export let fatalErrRegex = new RegExp(
'^[0-9:.]+\\s\\([0-9]+\\)\\|FATAL_ERROR\\|(.)+'
);
export let expThrownRegex = new RegExp(
'^[0-9:.]+\\s\\([0-9]+\\)\\|(EXCEPTION_THROWN\\|)[(\\[EXTERNAL\\])(0-9)]+(\\|)(.)+'
);
30 changes: 30 additions & 0 deletions src/modules/ui/logErrors/logErrors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.slds-popover {
position: absolute;
bottom: 1.5rem;
}

.line-btn {
padding: 0px;
line-height: normal;
color: #0070d2;
border: none;
box-shadow: none;
}

.line-btn:hover {
text-decoration: underline;
box-shadow: none;
}

.slds-popover__body p {
line-height: normal;
}

.err-event {
color: #ba0517;
}

.err-body {
max-height: 25rem;
overflow: auto;
}
Loading