50 std::string
getLogLocation(
const char *file,
int line,
const char *func);
71 void log(
const std::string &message);
78 void log(
const char *message);
96 std::lock_guard<std::mutex> lock(_mtx);
115 std::lock_guard<std::mutex> lock(_mtx);
135 std::lock_guard<std::mutex> lock(_mtx);
136 if (os ==
static_cast<std::ostream & (*)(std::ostream &)
>(std::endl)) {
166 bool _stringDebug =
false;
167 bool _logEnabled =
false;
168 bool _debugEnabled =
false;
171 std::ostringstream _buffer;
176 Log() : _debugEnabled(false) {}
178 Log(
const Log &) =
delete;
179 Log &operator=(
const Log &) =
delete;
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.
Log & operator<<(const std::string &message)
Appends a string message to the debug log if debugging is enabled.
static Log & getInstance(const bool debug=false)
Provides access to the singleton instance of the Debug class.
Log & operator<<(const T &message)
Appends a message to the debug log if debugging is enabled.
Log & operator<<(std::ostream &(*os)(std::ostream &))
Handles special stream manipulators (e.g., std::endl) for logging with timestamps if debugging is ena...
void setDebugEnabled(bool enabled)
Enables or disables the debug logging.
std::string getCurrentDateTime()
Retrieves the current date and time as a formatted string.
bool isRedirected()
Check if the output is being redirected to a file.