Created
December 6, 2018 05:25
-
-
Save isitavi/03cae34b20aea9e19c003cc1e17d5494 to your computer and use it in GitHub Desktop.
parseLogs-Problem2
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> | |
<body> | |
<button id="btn">Parse Logs</button> | |
<div id="result"></div> | |
<script src="logParser.js"></script> | |
</body> | |
</html> |
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
const firstPattern = /iwjef99/igm, | |
secondPattern = /w89fj93/igm, | |
thirdPattern = /7sjeuf/igm, | |
fourthPattern = /a99jef9/igm, | |
fifthPattern = /7sjeuf/igm, | |
sixthPattern = /98w9jfi9/igm, | |
seventhPatten = /a9i5f/igm, | |
eightPatten = /i9wjf99/igm, | |
ninthPattern = /63di9/igm, | |
tenthPattern = /8efkwi/igm | |
document.getElementById('btn').addEventListener('click', () => { | |
fetch('logs.txt') | |
.then(response => response.text()) | |
.then(text => [text].forEach((element) => { | |
if (element.match(firstPattern)) { | |
console.log(element.match(firstPattern).length) | |
console.log(element.match(firstPattern)) | |
} | |
if (element.match(secondPattern)) { | |
console.log(element.match(secondPattern).length) | |
console.log(element.match(secondPattern)) | |
} | |
if (element.match(thirdPattern)) { | |
console.log(element.match(thirdPattern).length) | |
console.log(element.match(thirdPattern)) | |
printVal = `${element.match(thirdPattern)}` | |
} | |
if (element.match(fourthPattern)) { | |
console.log(element.match(fourthPattern).length) | |
console.log(element.match(fourthPattern)) | |
} | |
if (element.match(fifthPattern)) { | |
console.log(element.match(fifthPattern).length) | |
console.log(element.match(fifthPattern)) | |
} | |
if (element.match(sixthPattern)) { | |
console.log(element.match(sixthPattern).length) | |
console.log(element.match(sixthPattern)) | |
} | |
if (element.match(seventhPatten)) { | |
console.log(element.match(seventhPatten).length) | |
console.log(element.match(seventhPatten)) | |
} | |
if (element.match(eightPatten)) { | |
console.log(element.match(eightPatten).length) | |
console.log(element.match(eightPatten)) | |
} | |
if (element.match(ninthPattern)) { | |
console.log(element.match(ninthPattern).length) | |
console.log(element.match(ninthPattern)) | |
} | |
if (element.match(tenthPattern)) { | |
console.log(element.match(tenthPattern).length) | |
console.log(element.match(tenthPattern)) | |
} | |
})) | |
}) |
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
2017-02-09T02:37:44 [ERROR] Consumer iwjef99 could not be contacted | |
2017-02-09T02:37:46 [INFO] Message received from Producer w89fj93 | |
2017-02-09T02:37:51 [ERROR] Consumer 7sjeuf returned 504 | |
2017-02-09T02:37:53 [INFO] Message received from Producer a99jef9 | |
2017-02-09T02:37:59 [INFO] Message sent to Consumer a99jef9 | |
2017-02-09T02:38:02 [INFO] Message received from Producer a99jef9 | |
2017-02-09T02:38:08 [INFO] Message received from Producer 7sjeuf | |
2017-02-09T02:38:10 [INFO] Message sent to Consumer 98w9jfi9 | |
2017-02-09T02:38:10 [INFO] Message sent to Consumer a9i5f | |
2017-02-09T02:38:12 [INFO] Message received from Producer 98w9jfi9 | |
2017-02-09T02:38:15 [INFO] Message received from Producer w89fj93 | |
2017-02-09T02:38:17 [INFO] Message sent to Consumer i9wjf99 | |
2017-02-09T02:38:21 [INFO] Message sent to Consumer 7sjeuf | |
2017-02-09T02:38:27 [INFO] Message received from Producer iwjef99 | |
2017-02-09T02:38:29 [INFO] Message received from Producer i9wjf99 | |
2017-02-09T02:38:31 [INFO] Message received from Producer i9wjf99 | |
2017-02-09T02:38:35 [INFO] Message received from Producer 98w9jfi9 | |
2017-02-09T02:38:40 [INFO] Message received from Producer 7sjeuf | |
2017-02-09T02:38:40 [INFO] Message sent to Consumer w89fj93 | |
2017-02-09T02:38:44 [INFO] Message received from Producer i9wjf99 | |
2017-02-09T02:38:49 [INFO] Message received from Producer 98w9jfi9 | |
2017-02-09T02:38:55 [ERROR] Consumer a99jef9 disconnected unexpectedly | |
2017-02-09T02:38:55 [ERROR] Consumer i9wjf99 returned 503 | |
2017-02-09T02:38:58 [INFO] Message received from Producer w89fj93 | |
2017-02-09T02:39:02 [INFO] Message received from Producer iwjef99 | |
2017-02-09T02:39:04 [INFO] Message sent to Consumer a99jef9 | |
2017-02-09T02:39:07 [INFO] Message sent to Consumer 98w9jfi9 | |
2017-02-09T02:39:11 [INFO] Message received from Producer 63di9 | |
2017-02-09T02:39:15 [INFO] Message sent to Consumer 8efkwi | |
2017-02-09T02:39:20 [INFO] Message sent to Consumer a99jef9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment