24 #define isatty _isatty
25 #define fileno _fileno
56 std::string
getLogLocation(
const char *file,
int line,
const char *func);
91 void log(
const std::string &message);
98 void log(
const char *message);
110 template <
typename T>
114 std::lock_guard<std::mutex> lock(_mtx);
132 std::lock_guard<std::mutex> lock(_mtx);
151 std::lock_guard<std::mutex> lock(_mtx);
152 if (os ==
static_cast<std::ostream & (*)(std::ostream &)
>(std::endl)) {
180 bool _stringDebug =
false;
181 bool _logEnabled =
false;
182 bool _debugEnabled =
false;
185 std::ostringstream _buffer;
192 Log(
const Log &) =
delete;
193 Log &operator=(
const Log &) =
delete;
204 return !isatty(fileno(stdout));
Provides custom operator<< overloads for various types.
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 logging is enabled.
void setStringAsDebug(const bool stringDebug=false)
Sets the internal boolean _stringDebug.
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 logging.
Log & operator<<(const std::string &message)
Appends a string message to the log if logging is enabled.
static Log & getInstance(const bool debug=false)
Provides access to the singleton instance of the Log class.
const bool getDebugEnabled() const
Checks if debug logging is enabled.
Log & operator<<(const T &message)
Appends a message to the log if logging is enabled.
Log & operator<<(std::ostream &(*os)(std::ostream &))
Handles special stream manipulators (e.g., std::endl) for logging with timestamps if logging is enabl...
void setDebugEnabled(bool enabled)
Enables or disables debug logging.
std::string getCurrentDateTime()
Retrieves the current date and time as a formatted string.
const bool getLogEnabled() const
Checks if logging is enabled.
bool isRedirected()
Checks if the output is being redirected to a file.