|
Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
|
Writes simulation events to the console and, optionally, to a file. More...
#include <Logger.h>
Public Member Functions | |
| Logger (bool verbose, bool useColor) | |
| Creates a logger. | |
| bool | openEventFile (const std::string &path) |
| Copies events to a file in addition to the console. | |
| bool | verbose () const |
| void | log (LogCategory category, unsigned long cycle, const std::string &source, const std::string &message) |
| Logs one event. | |
| std::string | colorize (LogCategory category, const std::string &text) const |
| Wraps text in an ANSI color for console output when colors are enabled. | |
Writes simulation events to the console and, optionally, to a file.
Two modes are supported:
ANSI colors are used only when standard output is a terminal and color has not been disabled. Files never contain color codes.
| Logger::Logger | ( | bool | verbose, |
| bool | useColor ) |
Creates a logger.
| verbose | True to print every event; false for quiet mode. |
| useColor | True to allow ANSI colors on a terminal. |
Definition at line 19 of file Logger.cpp.
| bool Logger::openEventFile | ( | const std::string & | path | ) |
Copies events to a file in addition to the console.
| path | File to create or overwrite. |
Definition at line 22 of file Logger.cpp.
| bool Logger::verbose | ( | ) | const |
Definition at line 27 of file Logger.cpp.
| void Logger::log | ( | LogCategory | category, |
| unsigned long | cycle, | ||
| const std::string & | source, | ||
| const std::string & | message ) |
Logs one event.
| category | Event kind; Arrival/Assign/Complete/Reject/Discard/Scale events appear only in verbose mode. |
| cycle | Clock cycle of the event. |
| source | Name of the load balancer reporting the event. |
| message | Event text. |
Definition at line 68 of file Logger.cpp.
| std::string Logger::colorize | ( | LogCategory | category, |
| const std::string & | text ) const |
Wraps text in an ANSI color for console output when colors are enabled.
| category | Category whose color to use. |
| text | Text to color. |
Definition at line 61 of file Logger.cpp.