I am in the process of creating a health monitor based on the output of a logfile.txt. I'm reading the entire log into an array, then working the array within a for loop.
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "EarLog.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4 && txtFile.status === 200) {
allText = txtFile.responseText;
lines = txtFile.responseText.split("\n");
}
var i = 0;
var name;
var status;
for (i = 5; i < 31; i++) {
var res = lines[i].split(": ");
name = res[0]
status = res[1];
}
document.write("<br>" + name[1] + "<br>")
}
txtFile.send(null);
And here is the part of the log file that I am reading from.
"Checkout Started at 14:52:11.57 :: Fri 07/24/2015"
StarTeam 11.0 Command Line Interface, Build 11.0.0.82
Copyright (c) 2003-2009 Borland Software Corporation. All rights reserved.
Using ini file: C:\ProgramData\Borland\StarTeam\ConnectionManager.ini
Folder: deployment (working dir: C:\Deployment\EARS\FutureRelease)
servicing.ear: skipped
portal.ear: checked out
.
.
.
communications.ear: checked out
"Checkout Completed at 14:54:11.63 :: Fri 07/24/2015"
However, instead of name being populated with the name of each ear, it is being populated by each individual letter of the last line read, in this case communications.ear so when I try to write something like
document.write(name[10])
instead of displaying the tenth ear, it displays the tenth letter of the last ear read. The same issue also occurs for status. Basically I want to be able to call the variable name[1] and have it show the string "portal.ear" and call the variable status[1] and have it show the string "checked out", and so on.