16#include <source_location>
39 return std::cerr << input;
77 inline void indent(
auto& writer, [[maybe_unused]]
int indentLvl)
79#if defined(ALPAKA_LOG_INDENT)
80 for(
int i = 0; i < indentLvl; ++i)
81 i == 0 ? (writer <<
"|-") : (writer <<
"--");
94 inline std::string
adjStringLength(std::string str,
size_t n,
char const paddingCharacter =
' ')
100 str.resize(n, paddingCharacter);
110#if defined(ALPAKA_LOG_DETAIL_SHORT)
118 template<logger::concepts::Level T_LogLvl,
typename T_Writer = StdErr>
122 Scoped(T_LogLvl logLvl, std::source_location
const& location)
135 alpaka::unused(logLvl);
147 auto const endTime = std::chrono::high_resolution_clock::now();
148 double durationInSeconds = std::chrono::duration<double, std::milli>(endTime -
m_startTime).count();
168 template<logger::concepts::Level T_LogLvl,
typename T_Callable,
typename T_Writer = StdErr>
169 requires(std::is_invocable_r_v<std::string, T_Callable>)
173 Info(T_LogLvl logLvl, T_Callable
const& callable, std::source_location
const& location)
175 auto fullPrefix = std::string(
"[") +
adjStringLength(logLvl.getName(), 6) +
"]";
177 auto& writer = T_Writer::get();
178 std::stringstream ss;
180 writer << fullPrefix << ss.str();
181 indent(writer, writer.current());
182 writer << callable() <<
" " <<
adjDetails(location.function_name()) <<
" " << location.file_name() <<
":"
183 << location.line() << std::endl;
use source_location to derive the demangled type name based on: https://www.reddit....
std::string adjDetails(std::string const &str)
shortening the function signatures to become human-readable
std::string adjStringLength(std::string str, size_t n, char const paddingCharacter=' ')
Adjust the length of a string to a minimum length.
void indent(auto &writer, int indentLvl)
Indent the message if needed and forward it to the output writer.
std::string simplifyFunctionSignature(std::string const &deName)
Simplify the C++ signature of a function.
std::convertible_to< std::string > auto getName(auto &&any)
Runtime name for a given object.
constexpr decltype(auto) get(concepts::SpecializationOf< Dict > auto &t) noexcept
Info(T_LogLvl logLvl, T_Callable const &callable, std::source_location const &location)
Info & operator=(Info const &)=delete
Info(Info const &)=delete
Info & operator=(Info &&)=delete
decltype(std::chrono::high_resolution_clock::now()) m_startTime
Scoped(T_LogLvl logLvl, std::source_location const &location)
std::string m_functionName
Scoped(Scoped const &)=delete
Scoped & operator=(Scoped &&)=delete
Scoped & operator=(Scoped const &)=delete
Write all output to std::cerr.
std::atomic< int > indentLvl
std::ostream & operator<<(auto const &input) const
int leave()
decrease the indention level
int enter()
increase the indention level
int current()
current indention level