Files
LumberJack_TUI/log_parsing/log_parsing.hpp
rapturate 42f50c9e9a 1) First draft of the TUI functionality
2) Added env_reader functions (env.hpp and env.cpp)
3) Program looks for a .env on startup and creates one based on user input if not found.
4) Refactored log_parsing and ip_to_geo to use the global env variables for parsing and ip lookup from the local .mmdb database
5) CMakeLists.txt is now cross platform functional
6) Added various cross platform checks for creating .env variables
2026-06-09 14:29:42 -04:00

120 lines
2.6 KiB
C++

/**
* @file log_parsing.h
* @author Lew Price (lewis.e.price@outlook.com)
* @brief A series of functions for parsing the access logs of an Apache2 webserver.
* @version 0.1
* @date 2026-05-28
*
* @copyright Copyright (c) 2026
*
*/
#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;
std::string bytes;
std::string referer;
std::string os;
std::string browser;
};
class p_logs {
private:
Entry entry;
std::vector<Entry> logs;
std::string url;
public:
/**
* @brief Construct a new parsed logs object
* Detailed explanation: This function takes in the absolute path to a .log file and parses the lines into individual "Entry"s. These Entrys are then stored into a vector that can then be accessed via getter functions.
* @param string
*/
p_logs(std::string);
std::vector<Entry> get_all_logs();
/**
* @brief Getter function for a specific Entry's IP
*
* @param int
* @return std::string
*/
std::string entryx_ip(int);
/**
* @brief Getter function for a specific Entry's time stamp
*
* @param int
* @return std::string
*/
std::string entryx_timestamp(int);
/**
* @brief Getter function for a specific Entry's request
*
* @param int
* @return std::string
*/
std::string entryx_request(int);
/**
* @brief Getter function for a specific Entry's status
*
* @param int
* @return std::string
*/
std::string entryx_status(int);
/**
* @brief Getter function for a specific Entry's byte size
*
* @param int
* @return std::string
*/
std::string entryx_bytes(int);
/**
* @brief Getter function for a specific Entry's referer
*
* @param int
* @return std::string
*/
std::string entryx_referer(int);
/**
* @brief Getter function for a specific Entry's OS info
*
* @param int
* @return std::string
*/
std::string entryx_os(int);
/**
* @brief Getter function for a specific Entry's browser info
*
* @param int
* @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
*
*/
void print_logs();
};