Load Balancer Simulation
A simulation of a load balancer with dynamic server scaling in C++
Loading...
Searching...
No Matches
Logger.h
Go to the documentation of this file.
1
5
6#ifndef LOGGER_H
7#define LOGGER_H
8
9#include <string>
10#include <fstream>
11
19class Logger {
20public:
26 static bool init(const std::string& filename);
27
31 static void close();
32
39 static void log(const std::string& message);
40
45 static bool isOpen() { return logFile_.is_open(); }
46
47private:
48 static std::ofstream logFile_;
49
55 static std::string stripAnsi(const std::string& str);
56};
57
58#endif
Static logger that writes to both console and a log file.
Definition Logger.h:19
static std::string stripAnsi(const std::string &str)
Remove ANSI escape sequences from a string.
Definition Logger.cpp:29
static bool isOpen()
Check if the log file is currently open.
Definition Logger.h:45
static std::ofstream logFile_
Definition Logger.h:48
static bool init(const std::string &filename)
Initialize the logger with an output file.
Definition Logger.cpp:13
static void log(const std::string &message)
Write a message to both console and log file.
Definition Logger.cpp:36
static void close()
Close the log file.
Definition Logger.cpp:22