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:
rapturate
2026-06-08 14:25:11 -04:00
parent 1a129a5999
commit bdaf8451a0
6 changed files with 41 additions and 18 deletions

View File

@@ -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"

View File

@@ -12,9 +12,11 @@
#pragma once
#include <string>
#include <vector>
#include "../ip_to_geo/ip_to_geo.hpp"
struct Entry {
std::string ip;
loc_data location;
std::string timestamp;
std::string request;
std::string status;
@@ -100,7 +102,14 @@ public:
* @return std::string
*/
std::string entryx_browser(int);
/**
* @brief Getter function for a specific Entry's location info.
*
* @return loc_data
*/
loc_data entryx_location(int);
/**
* @brief Prints all parsed log entries
*