Patch - Doc Update - V12.8.1
This commit is contained in:
@@ -13,16 +13,27 @@
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Get the singleton instance of the Logger class.
|
||||
* @return A reference to the Logger instance.
|
||||
*/
|
||||
static Logger& Get()
|
||||
{
|
||||
static Logger instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the copy constructor and assignment operator to prevent copying.
|
||||
*/
|
||||
Logger(Logger const&) = delete;
|
||||
void operator=(Logger const&) = delete;
|
||||
|
||||
/**
|
||||
* Enum class representing different log levels.
|
||||
* Each log level has a corresponding color for display purposes.
|
||||
* The last entry, Count, is used to determine the number of log levels.
|
||||
*/
|
||||
enum class LogLevel
|
||||
{
|
||||
Info,
|
||||
@@ -47,12 +58,20 @@ public:
|
||||
// Return the size of the enum class LogLevel as a constant integer
|
||||
static constexpr int LogLevelCount = static_cast<int>(LogLevel::Count);
|
||||
|
||||
/**
|
||||
* Struct representing a log entry.
|
||||
* Contains the log message and its associated log level.
|
||||
*/
|
||||
struct LogEntry
|
||||
{
|
||||
std::string message;
|
||||
LogLevel level;
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct containing information about a log level.
|
||||
* This includes the name of the log level, its value, and its color for display.
|
||||
*/
|
||||
struct LogLevelInfo
|
||||
{
|
||||
const char* name;
|
||||
@@ -60,6 +79,12 @@ public:
|
||||
ImVec4 color;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the LogLevelInfo for a given log level.
|
||||
* This function returns a LogLevelInfo struct containing the name, value, and color of the log level.
|
||||
* @param level The log level for which to get the information.
|
||||
* @return A LogLevelInfo struct containing the information for the specified log level.
|
||||
*/
|
||||
static const LogLevelInfo GetLogLevelInfo(LogLevel level)
|
||||
{
|
||||
switch (level)
|
||||
@@ -84,6 +109,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the Logger class.
|
||||
* Initializes the logger, sets up the log file path, and manages log files.
|
||||
*/
|
||||
Logger()
|
||||
{
|
||||
char* appdata = nullptr;
|
||||
@@ -119,7 +148,13 @@ public:
|
||||
|
||||
}
|
||||
|
||||
// ecrit un message dans le fichier de log et le stocke dans le buffer
|
||||
/**
|
||||
* Write a log message to the log file and console.
|
||||
* @param message
|
||||
* @param fileName
|
||||
* @param lineNumber
|
||||
* @param level
|
||||
*/
|
||||
void Log(const std::string& message, const std::string& fileName, int lineNumber, LogLevel level = LogLevel::Info)
|
||||
{
|
||||
|
||||
@@ -152,7 +187,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// ecrit un message dans la console
|
||||
/**
|
||||
* Write a log message to the log buffer.
|
||||
* This is the fonction wich is used to send log messages to the gui.
|
||||
* It's using a buffer to store the log messages with a maximum size.
|
||||
* The buffer default size is 100 messages.
|
||||
* This limit can be changed by changing the logBufferSize variable.
|
||||
* But it is not recommended to change it because it can cause performance issues.
|
||||
* @param message The log message to write.
|
||||
* @param level The log level for the message.
|
||||
*/
|
||||
void Log(const std::string& message, LogLevel level)
|
||||
{
|
||||
|
||||
@@ -169,8 +213,20 @@ public:
|
||||
logBuffer.push_back({ message, level });
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the loggBuffer deque.
|
||||
* @return A constant reference to the logBuffer deque containing log entries.
|
||||
*/
|
||||
const std::deque<LogEntry>& GetLogBuffer() const { return logBuffer; }
|
||||
|
||||
/**
|
||||
* This function manages log files in the specified directory.
|
||||
* It checks for log files with the ".log" extension,
|
||||
* Then it keeps only the three most recent log files,
|
||||
* deleting the oldest ones if there are more than three.
|
||||
* It also creates a new log file for the current execution with a timestamp in its name.
|
||||
* @param directoryPath
|
||||
*/
|
||||
void ManageLogFiles(const std::string& directoryPath)
|
||||
{
|
||||
std::vector<std::filesystem::path> logFiles;
|
||||
|
Reference in New Issue
Block a user