增加了堆栈错误打印

pull/1/head
剑古敛锋 2024-07-23 10:25:24 +08:00
parent de338b2cb9
commit 2a5156f329
2 changed files with 21 additions and 0 deletions

View File

@ -1,9 +1,17 @@
#include "DebugLogger.h"
#include <boost/stacktrace.hpp>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <windows.h>
#include <dbghelp.h>
#include <stdio.h>
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
#define filename(x) strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x
#else
@ -11,6 +19,14 @@
#endif
namespace Common {
void function_to_trace() {
std::cout << "Stack trace:" << std::endl;
std::cout << boost::stacktrace::stacktrace() << std::endl;
}
void DebugLogger::info(const char* file, int line, const char* format, ...)
{
va_list args;

View File

@ -25,8 +25,12 @@
#include "CommonAPI.h"
#include <cstdarg>
namespace Common {
class COMMONAPI DebugLogger {
public:
@ -42,6 +46,7 @@ namespace Common {
static char* currentTime();
static void output(const char* file, int line, const char* format, int level, va_list args);
};
void COMMONAPI function_to_trace();
} // namespace Common
// 用宏OUTPUT_DEBUG_INFO控制调试信息是否输出的开关