-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogParser.h
More file actions
27 lines (22 loc) · 783 Bytes
/
LogParser.h
File metadata and controls
27 lines (22 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once
#include <string>
#include <vector>
#include "LogEntry.h"
class LogParser {
public:
// Parse a log file and return all entries
std::vector<LogEntry> parseFile(const std::string& filepath);
// Parse a single line into a LogEntry
LogEntry parseLine(const std::string& line, int lineNumber);
int getTotalLines() const { return totalLines; }
int getSkippedLines() const { return skippedLines; }
private:
int totalLines = 0;
int skippedLines = 0;
// Supported formats:
// [2024-01-15 10:30:45] [ERROR] [source] message
// 2024-01-15 10:30:45 ERROR message
// ERROR: message
bool parseStandardFormat(const std::string& line, LogEntry& entry);
bool parseSimpleFormat(const std::string& line, LogEntry& entry);
};