Reading a logfile
The first task for our current mission is to take the logfile of an Apache web server and extract the interesting parts. We are going to use regular expressions to split the logfiles' lines and we are fetching the IP address and the timestamp. We will also create a new class to store the data we have extracted.
Engage Thrusters
Let's start with parsing our logfile:
Create a new sketch and add the
setup()
anddraw()
methods.void setup() { } void draw() { }
Now we add the logfile we want to visualize by dropping it on the sketch window or adding it using the Sketch | Add File ... menu.
In the
setup()
method, we read the file into an array of strings.void setup() { size(700,350); String[] log = loadStrings( "access.log" ); }
Add a new tab by clicking on the little arrow icon and selecting New Tab. We name it
LogRow
and create a new class to store the IP address and the timestamp of each record.class LogRow { String ip; String timestamp; public LogRow( String ip,...