Switched my header files to .hpp for clarity
This commit is contained in:
103
log_parsing/log_parsing.hpp
Normal file
103
log_parsing/log_parsing.hpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @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 <regex>
|
||||
#include <string>
|
||||
|
||||
struct Entry {
|
||||
std::string ip;
|
||||
std::string timestamp;
|
||||
std::string request;
|
||||
std::string status;
|
||||
std::string bytes;
|
||||
std::string referer;
|
||||
std::string os;
|
||||
std::string browser;
|
||||
};
|
||||
|
||||
class parsed_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
|
||||
*/
|
||||
parsed_logs(std::string);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
};
|
||||
Reference in New Issue
Block a user