-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(log): added parseErrorsAndWarnings utility
- Loading branch information
1 parent
15774ec
commit 7c1c1e2
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './log' | ||
export * from './types' | ||
export * from './helper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export const parseErrorsAndWarnings = (log: string) => { | ||
const logLines = log.split('\n') | ||
const errorLines: string[] = [] | ||
const warningLines: string[] = [] | ||
|
||
logLines.forEach((line: string, index: number) => { | ||
// INFO: check if content in element starts with ERROR | ||
if (/<.*>ERROR/gm.test(line)) { | ||
const errorLine = line.substring(line.indexOf('E'), line.length - 1) | ||
errorLines.push(errorLine) | ||
} | ||
|
||
// INFO: check if line starts with ERROR | ||
else if (/^ERROR/gm.test(line)) { | ||
errorLines.push(line) | ||
|
||
logLines[index] = | ||
`<font id="error_${errorLines.length - 1}">` + | ||
logLines[index] + | ||
'</font>' | ||
} | ||
|
||
// INFO: check if content in element starts with WARNING | ||
else if (/<.*>WARNING/gm.test(line)) { | ||
const warningLine = line.substring(line.indexOf('W'), line.length - 1) | ||
warningLines.push(warningLine) | ||
} | ||
|
||
// INFO: check if line starts with WARNING | ||
else if (/^WARNING/gm.test(line)) { | ||
warningLines.push(line) | ||
|
||
logLines[index] = | ||
`<font id="warning_${warningLines.length - 1}">` + | ||
logLines[index] + | ||
'</font>' | ||
} | ||
}) | ||
|
||
return { errors: errorLines, warnings: warningLines, logLines } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters