Allowed pointers to be logged/printed
This commit is contained in:
@@ -156,7 +156,16 @@ namespace LXC::Util
|
||||
requires Internal::HasLogStrFunc<T> || Internal::Logable<T>
|
||||
inline void PrintLn(T&& arg)
|
||||
{
|
||||
if constexpr (Internal::HasLogStrFunc<T>)
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
if (arg != nullptr) _LIKELY
|
||||
PrintLn(*arg);
|
||||
|
||||
else
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, "Nullptr to: [", typeid(std::remove_pointer_t<T>).name(), "]");
|
||||
}
|
||||
|
||||
else if constexpr (Internal::HasLogStrFunc<T>)
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, arg.LogStr());
|
||||
|
||||
else
|
||||
@@ -176,12 +185,21 @@ namespace LXC::Util
|
||||
// Logs a singular argument to the log, calls Log() if it can on the object //
|
||||
template<typename T>
|
||||
requires Internal::HasLogStrFunc<T> || Internal::Logable<T>
|
||||
inline void Log(T arg)
|
||||
inline void Log(T&& arg)
|
||||
{
|
||||
std::ofstream& log = Internal::Log();
|
||||
if (log.is_open()) _UNLIKELY
|
||||
{
|
||||
if constexpr (Internal::HasLogStrFunc<T>)
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
if (arg != nullptr) _LIKELY
|
||||
Log(*arg);
|
||||
|
||||
else
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] Nullptr to: [", typeid(std::remove_pointer_t<T>).name(), "]");
|
||||
}
|
||||
|
||||
else if constexpr (Internal::HasLogStrFunc<T>)
|
||||
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] ", '{', arg.LogStr(), '}');
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user