Skip code when not logging

This commit is contained in:
FakeMichau
2024-09-10 04:41:54 +02:00
parent 29fb42b103
commit ba9bf7f158
+5 -2
View File
@@ -30,18 +30,21 @@ inline std::string extractFunctionName(const std::string& signature) {
}
void log(const std::string& log) {
if (logStream == &null) return;
std::ostringstream oss;
oss << "[" << getCurrentTimeFormatted() << "] " << log << std::endl;
*logStream << oss.str();
}
NvAPI_Status Ok(const std::source_location& location) {
// log(std::format("{}: {}", extractFunctionName(location.function_name()), "OK"));
if (logStream != &null)
log(std::format("{}: {}", extractFunctionName(location.function_name()), "OK"));
return NVAPI_OK;
}
NvAPI_Status Error(NvAPI_Status status, const std::source_location& location) {
log(std::format("{}: {}", extractFunctionName(location.function_name()), fromErrorNr(status)));
if (logStream != &null)
log(std::format("{}: {}", extractFunctionName(location.function_name()), fromErrorNr(status)));
return status;
}