added location info into the log_parsing output. Now when the access logs are parsed, the geo_data is now included in the p_logs print function for each entry.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <regex>
|
||||
|
||||
#include "log_parsing.hpp"
|
||||
//#include "../ip_to_geo/ip_to_geo.hpp"
|
||||
#include "../ip_to_geo/ip_to_geo.hpp"
|
||||
|
||||
p_logs::p_logs(std::string log_path) {
|
||||
|
||||
@@ -51,6 +51,8 @@ p_logs::p_logs(std::string log_path) {
|
||||
else if (raw_ua.find("curl/") != std::string::npos) current_entry.browser = "curl (CLI Tool)";
|
||||
else current_entry.browser = "Unknown Browser/Bot";
|
||||
|
||||
current_entry.location = iplookup(current_entry.ip);
|
||||
|
||||
logs.push_back(current_entry);
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,12 @@ void p_logs::print_logs() {
|
||||
std::ios_base::sync_with_stdio(false);
|
||||
for (const auto& log : logs) {
|
||||
std::cout << "IP: " << log.ip.c_str() << "\n"
|
||||
<< "Location:" << "\n"
|
||||
<< "\tCountry: " << log.location.country << "\n"
|
||||
<< "\tSubdivision: " << log.location.subdivision << "\n"
|
||||
<< "\tCity: " << log.location.city << "\n"
|
||||
<< "\tLongitude: " << log.location.longitude << "\n"
|
||||
<< "\tLatitude: " << log.location.latitutde << "\n"
|
||||
<< "Timestamp: " << log.timestamp.c_str() << "\n"
|
||||
<< "Request: " << log.request.c_str() << "\n"
|
||||
<< "Status: " << log.status.c_str() << "\n"
|
||||
|
||||
Reference in New Issue
Block a user