1 #ifndef SIPLASPLAS_UTILITY_ERRORLOGGER_HPP 2 #define SIPLASPLAS_UTILITY_ERRORLOGGER_HPP 4 #include <siplasplas/logger/logger.hpp> 5 #include <backward-cpp/backward.hpp> 6 #include <fmt/format.h> 7 #include <siplasplas/utility/export.hpp> 36 SIPLASPLAS_UTILITY_EXPORT spdlog::logger&
errorLogger();
83 template<
typename Message,
typename... Args>
86 using namespace backward;
87 static constexpr std::size_t MAX_FRAMES = 32;
88 StackTrace stackTrace;
89 TraceResolver traceResolver;
90 stackTrace.load_here(MAX_FRAMES);
91 traceResolver.load_stacktrace(stackTrace);
93 const std::size_t FRAMES_COUNT = stackTrace.size();
99 for(std::size_t i = 0; i < FRAMES_COUNT - framesToSkip; ++i)
101 const auto& trace = traceResolver.resolve(stackTrace[FRAMES_COUNT - i - 1]);
104 "#{} \"{}\", at {}, in {}",
105 FRAMES_COUNT - framesToSkip - i,
106 trace.object_filename,
108 trace.object_function
113 errorLogger().critical(fmt::format(message, std::forward<Args>(args)...));
129 template<
typename Message,
typename... Args>
130 void logError(
const Message& message, Args&&... args)
139 #endif // SIPLASPLAS_UTILITY_ERRORLOGGER_HPP Definition: canary_allocator.hpp:7
void logError(const Message &message, Args &&...args)
Logs an error with its backtrace. See cpp::logErrorSkippingFrames().
Definition: error_logger.hpp:130
void logErrorSkippingFrames(std::size_t framesToSkip, const Message &message, Args &&...args)
Log an error with its backtrace. Also skip the latest framesToSkip stack frames from stack trace...
Definition: error_logger.hpp:84
SIPLASPLAS_UTILITY_EXPORT spdlog::logger & errorLogger()
Isolated logger for detailed error logging.