Aggie Student Toolkit — Load Balancer
CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Toggle main menu visibility
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1
6
7
#ifndef LOGGER_H
8
#define LOGGER_H
9
10
#include <fstream>
11
#include <string>
12
16
enum class
LogCategory
{
17
Arrival
,
18
Assign
,
19
Complete
,
20
Reject
,
21
Discard
,
22
ScaleUp
,
23
ScaleDown
,
24
Status
,
25
Info
26
};
27
40
class
Logger
{
41
public
:
47
Logger
(
bool
verbose
,
bool
useColor);
48
54
bool
openEventFile
(
const
std::string& path);
55
57
bool
verbose
()
const
;
58
66
void
log
(
LogCategory
category,
unsigned
long
cycle,
const
std::string& source,
67
const
std::string& message);
68
75
std::string
colorize
(
LogCategory
category,
const
std::string& text)
const
;
76
77
private
:
78
static
const
char
* label(
LogCategory
category);
79
static
const
char
* color(
LogCategory
category);
80
81
bool
verbose_;
82
bool
useColor_;
83
std::ofstream eventFile_;
84
};
85
86
#endif
LogCategory
LogCategory
Kind of event being logged; selects the color and whether quiet mode shows it.
Definition
Logger.h:16
LogCategory::Assign
@ Assign
A queued request was dispatched to a server.
Definition
Logger.h:18
LogCategory::Info
@ Info
General information such as start-up messages.
Definition
Logger.h:25
LogCategory::Arrival
@ Arrival
A request entered the queue.
Definition
Logger.h:17
LogCategory::ScaleDown
@ ScaleDown
A server was removed or marked for retirement.
Definition
Logger.h:23
LogCategory::Complete
@ Complete
A server finished a request.
Definition
Logger.h:19
LogCategory::Discard
@ Discard
The queue was full and a request was dropped.
Definition
Logger.h:21
LogCategory::Reject
@ Reject
The firewall blocked a request.
Definition
Logger.h:20
LogCategory::Status
@ Status
Periodic queue and server status line.
Definition
Logger.h:24
LogCategory::ScaleUp
@ ScaleUp
A server was added or returned to service.
Definition
Logger.h:22
Logger::openEventFile
bool openEventFile(const std::string &path)
Copies events to a file in addition to the console.
Definition
Logger.cpp:22
Logger::verbose
bool verbose() const
Definition
Logger.cpp:27
Logger::log
void log(LogCategory category, unsigned long cycle, const std::string &source, const std::string &message)
Logs one event.
Definition
Logger.cpp:68
Logger::Logger
Logger(bool verbose, bool useColor)
Creates a logger.
Definition
Logger.cpp:19
Logger::colorize
std::string colorize(LogCategory category, const std::string &text) const
Wraps text in an ANSI color for console output when colors are enabled.
Definition
Logger.cpp:61
Logger.h
Generated by
1.18.0