25 std::ostringstream oss;
26 oss << file <<
":" << line <<
" " << func <<
"()";
32 _logEnabled = enabled;
37 _debugEnabled = enabled;
46 if (_stringDebug && !_debugEnabled) {
50 std::lock_guard<std::mutex> lock(_mtxLog);
51 std::cout << getCurrentDateTime() << message << std::endl;
56 log(std::string(message));
61 _stringDebug = stringDebug;
66 auto now = std::chrono::system_clock::now();
67 std::time_t currentTime = std::chrono::system_clock::to_time_t(now);
68 auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(
69 now.time_since_epoch()
73 std::tm *tm = std::localtime(¤tTime);
76 ss <<
"[" << (tm->tm_year + 1900) <<
"-"
77 << (tm->tm_mon + 1) <<
"-"
82 << std::setfill(
'0') << std::setw(3) << millis <<
"]";
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
A singleton class that provides thread-safe logging capabilities with timestamps, active only when lo...
void log(const std::string &message)
Logs a message if debugging is enabled.
void setStringAsDebug(const bool stringDebug=false)
Function to set the internal boolean _stringAsDebug.
std::string getLogLocation(const char *file, int line, const char *func)
Generates a formatted debug information string with file, line, and function details.
void setLogEnabled(bool enabled)
Enables or disables the logging.
static Log & getInstance(const bool debug=false)
Provides access to the singleton instance of the Debug class.
void setDebugEnabled(bool enabled)
Enables or disables the debug logging.
std::string getCurrentDateTime()
Retrieves the current date and time as a formatted string.