14 #include <QLoggingCategory>
18 #include <backward.hpp>
27 #if defined(FREECIV_DEBUG) && !defined(FREECIV_TESTMATIC)
28 #define BACKTRACE_ACTIVE 1
31 #ifdef BACKTRACE_ACTIVE
32 #define MAX_NUM_FRAMES 64
37 static QtMessageHandler previous =
nullptr;
39 static void backtrace_log(QtMsgType type,
const QMessageLogContext &context,
41 void backtrace_print(QtMsgType type,
const QMessageLogContext &context);
50 #ifdef BACKTRACE_ACTIVE
51 previous = qInstallMessageHandler(backtrace_log);
60 #ifdef BACKTRACE_ACTIVE
61 qInstallMessageHandler(previous);
65 #ifdef BACKTRACE_ACTIVE
70 static void backtrace_log(QtMsgType type,
const QMessageLogContext &context,
73 if (type == QtFatalMsg || type == QtCriticalMsg) {
74 backtrace_print(type, context);
77 if (previous !=
nullptr) {
80 previous(type, context,
message);
89 void backtrace_print(QtMsgType type,
const QMessageLogContext &context)
91 if (!stack_category().isEnabled(QtDebugMsg)) {
97 using namespace backward;
99 st.load_here(MAX_NUM_FRAMES);
106 std::stringstream ss;
110 QMessageLogContext modified_context(context.file, context.line,
112 stack_category().categoryName());
116 while (std::getline(ss, line)) {
119 qCDebug(stack_category).noquote()
120 << qFormatLogMessage(type, modified_context, line.data());
void backtrace_init()
Take backtrace log callback to use.
void backtrace_deinit()
Remove backtrace log callback from use.
Q_LOGGING_CATEGORY(tileset_category, "freeciv.tileset")
Functions for handling the tilespec files which describe the files and contents of tilesets.