fileserver/src/util/crash.hxx
2023-10-23 13:59:50 +02:00

18 lines
506 B
C++

#ifndef FILESERVER_CRASH_HXX
#define FILESERVER_CRASH_HXX
#include <source_location>
#include <spdlog/spdlog.h>
// TODO implement backtrace
// TODO Send mail to admin on crash
[[noreturn]]
static void crash(std::source_location loc = std::source_location::current()) {
spdlog::critical("crash called from: {}:{} `{}`", loc.file_name(), loc.line(), loc.function_name());
spdlog::details::registry::instance().flush_all();
spdlog::shutdown();
std::abort();
}
#endif //FILESERVER_CRASH_HXX