mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 19:44:35 +00:00
feat(log): added parseErrorsAndWarnings utility
This commit is contained in:
@@ -9,7 +9,7 @@ import { PermissionsContext } from '../../../../context/permissionsContext'
|
|||||||
import {
|
import {
|
||||||
findExistingPermission,
|
findExistingPermission,
|
||||||
findUpdatingPermission
|
findUpdatingPermission
|
||||||
} from '../../../../utils/helper'
|
} from '../../../../utils'
|
||||||
|
|
||||||
const useAddPermission = () => {
|
const useAddPermission = () => {
|
||||||
const {
|
const {
|
||||||
|
|||||||
3
web/src/utils/index.ts
Normal file
3
web/src/utils/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './log'
|
||||||
|
export * from './types'
|
||||||
|
export * from './helper'
|
||||||
41
web/src/utils/log.ts
Normal file
41
web/src/utils/log.ts
Normal file
@@ -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 }
|
||||||
|
}
|
||||||
@@ -39,3 +39,9 @@ export interface TreeNode {
|
|||||||
isFolder: boolean
|
isFolder: boolean
|
||||||
children: Array<TreeNode>
|
children: Array<TreeNode>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LogObject {
|
||||||
|
body: string
|
||||||
|
errors: string[]
|
||||||
|
warnings: string[]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user