增加了堆栈错误打印
parent
de338b2cb9
commit
2a5156f329
|
|
@ -1,9 +1,17 @@
|
||||||
#include "DebugLogger.h"
|
#include "DebugLogger.h"
|
||||||
|
#include <boost/stacktrace.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <dbghelp.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
|
||||||
#define filename(x) strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x
|
#define filename(x) strrchr(x, '\\') ? strrchr(x, '\\') + 1 : x
|
||||||
#else
|
#else
|
||||||
|
|
@ -11,6 +19,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Common {
|
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, ...)
|
void DebugLogger::info(const char* file, int line, const char* format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,12 @@
|
||||||
|
|
||||||
#include "CommonAPI.h"
|
#include "CommonAPI.h"
|
||||||
|
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class COMMONAPI DebugLogger {
|
class COMMONAPI DebugLogger {
|
||||||
public:
|
public:
|
||||||
|
|
@ -42,6 +46,7 @@ namespace Common {
|
||||||
static char* currentTime();
|
static char* currentTime();
|
||||||
static void output(const char* file, int line, const char* format, int level, va_list args);
|
static void output(const char* file, int line, const char* format, int level, va_list args);
|
||||||
};
|
};
|
||||||
|
void COMMONAPI function_to_trace();
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
||||||
// 用宏OUTPUT_DEBUG_INFO控制调试信息是否输出的开关
|
// 用宏OUTPUT_DEBUG_INFO控制调试信息是否输出的开关
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue