streamable object to string function in logging
parent
463e36e48d
commit
ffeab29e5f
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
set(BLT_VERSION 2.0.8)
|
set(BLT_VERSION 2.0.9)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
||||||
|
|
|
@ -262,6 +262,14 @@ namespace blt::logging
|
||||||
|
|
||||||
void log_stream_internal(const std::string& str, const logger& logger);
|
void log_stream_internal(const std::string& str, const logger& logger);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline std::string to_string_stream(const T& t)
|
||||||
|
{
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << t;
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline static void log_stream(const T& t, const logger& logger)
|
inline static void log_stream(const T& t, const logger& logger)
|
||||||
{
|
{
|
||||||
|
@ -273,9 +281,7 @@ namespace blt::logging
|
||||||
log_stream_internal(t, logger);
|
log_stream_internal(t, logger);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
log_stream_internal(to_string_stream(t), logger);
|
||||||
stream << t;
|
|
||||||
log_stream_internal(stream.str(), logger);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,9 +301,7 @@ namespace blt::logging
|
||||||
log_internal(std::string(t), level, file, line, args);
|
log_internal(std::string(t), level, file, line, args);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
log_internal(to_string_stream(t), level, file, line, args);
|
||||||
stream << t;
|
|
||||||
log_internal(stream.str(), level, file, line, args);
|
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue