-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogFilter.h
More file actions
35 lines (30 loc) · 963 Bytes
/
LogFilter.h
File metadata and controls
35 lines (30 loc) · 963 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
28
29
30
31
32
33
34
35
#pragma once
#include <vector>
#include <string>
#include "LogEntry.h"
struct FilterOptions {
std::string level; // Filter by log level (e.g. "ERROR")
std::string keyword; // Filter by keyword in message
std::string source; // Filter by source/component
std::string afterTime; // Show entries after this timestamp
std::string beforeTime; // Show entries before this timestamp
};
class LogFilter {
public:
static std::vector<LogEntry> apply(
const std::vector<LogEntry>& entries,
const FilterOptions& opts
);
static std::vector<LogEntry> byLevel(
const std::vector<LogEntry>& entries,
LogLevel level
);
static std::vector<LogEntry> byKeyword(
const std::vector<LogEntry>& entries,
const std::string& keyword
);
static std::vector<LogEntry> bySource(
const std::vector<LogEntry>& entries,
const std::string& source
);
};