Clutter Engine 0.0.1
Loading...
Searching...
No Matches
CLog Class Reference

A logging utility class for handling console and file-based logging. More...

#include <CLog.h>

Public Types

enum class  LogLevel { INFO , WARNING , CERROR , LOG }
 Represents the severity level of a log message. More...
 

Static Public Member Functions

static void Init (const std::string &logName, const std::string &logFilePath="")
 Initializes the logging system.
 
static void Shutdown ()
 Shuts down the logging system and closes the log file.
 
template<typename... Args>
static void Log (LogLevel level, const std::string &message, const char *file, int line, Args... args)
 Logs a message to the console and/or a JSON file.
 

Detailed Description

A logging utility class for handling console and file-based logging.

This class provides static methods for logging messages to the console and to a JSON file. It supports different log levels and can be initialized and shut down as needed.

Member Enumeration Documentation

◆ LogLevel

enum class CLog::LogLevel
strong

Represents the severity level of a log message.

Enumerator
INFO 

Informational messages.

WARNING 

Warning messages.

CERROR 

Error messages.

LOG 

General log messages.

Member Function Documentation

◆ Init()

static void CLog::Init ( const std::string & logName,
const std::string & logFilePath = "" )
inlinestatic

Initializes the logging system.

Parameters
logNameThe name of the log file.
logFilePathThe directory path where the log file will be created. Defaults to an empty string.

This method creates the log directory if it does not exist and opens a new log file with a timestamp in its name. The log file is opened in truncation mode.

◆ Log()

template<typename... Args>
static void CLog::Log ( LogLevel level,
const std::string & message,
const char * file,
int line,
Args... args )
inlinestatic

Logs a message to the console and/or a JSON file.

Template Parameters
ArgsVariadic template for additional arguments to format the message.
Parameters
levelThe severity level of the log message.
messageThe log message format string.
fileThe source file where the log was generated.
lineThe line number in the source file where the log was generated.
argsAdditional arguments for formatting the message.

This method prints the formatted message to the console (if in EDITOR mode) and writes it to the JSON log file (if in _DEBUG mode).

◆ Shutdown()

static void CLog::Shutdown ( )
inlinestatic

Shuts down the logging system and closes the log file.

This method writes the closing bracket to the JSON log file and closes the file stream.


The documentation for this class was generated from the following file: