Given a text file of an http requests log, list the number of GET requests with response code 200
Output should be directed to a file as described in the below.
The format of the log file, a text file with a .txt extension, follows.
Each line contains a single log record with the following columns (in order):
The hostname of the host making the request.
Missing column value denoted by hyphen “-”
Missing column value denoted by hyphen “-”
A timestamp enclosed in square brackets following the format [DD/mm/YYY:HH:MM:SS-0400].
The request, enclosed in quotes(eg, “GET/images/NASA-logosmall.gif HTTP/1.0”).
The HTTP response code.
The total number of bytes sent in the response.
Function Description: Your function must create a unique list of hostnames with GET requests + response code of 200 and output to a file named “records_filename” where filename is replaced with input filename.
Each hostname should be followed by a space then the number of requests and a newline.
The filenames can appear in any order in output file
Constraints:
The log file has a maximum pf 200000 lines of records
Sample Input 0:
host_access_log_00.txt
Sample Output 0:
File Name:
records_host_access_log_00
** Content Of File:**
unicomp6.unicompt.net 4
burger.letters.com 1
Explanation 0:
The log file hosts_access_log_00.txt contains the following log records;
unicomp6.unicompt.net - - [01/AUG/2005:00:00:06 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985
burger.letters.com - - [01/AUG/2005:00:00:11 - 0400] "GET /shuttle/countdown/liftoff.html HTTP/1.0" 304 0
burger.letters.com - - [01/AUG/2005:00:00:12 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 304 0
burger.letters.com - - [01/AUG/2005:00:00:12 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 0
d104.aa.net - - [01/AUG/2005:00:00:13 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985
unicomp6.unicompt.net - - [01/AUG/2005:00:00:14 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 40310
unicomp6.unicompt.net - - [01/AUG/2005:00:00:14 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 786
unicomp6.unicompt.net - - [01/AUG/2005:00:00:14 - 0400] "GET /shuttle/countdown/ HTTP/1.0" 200 1204
d104.aa.net - - [01/AUG/2005:00:00:15 - 0400] "POST /shuttle/countdown/ HTTP/1.0" 200 40310
d104.aa.net - - [01/AUG/2005:00:00:15 - 0400] "POST /images/NASA-logosmall.gif HTTP/1.0" 200 786
Language preference (but not a restriction) C++