35 lines
516 B
C++
35 lines
516 B
C++
#pragma once
|
|
|
|
#include <a8/singleton.h>
|
|
|
|
#ifdef DEBUG
|
|
|
|
#if __GNUC__ > 4
|
|
#include <backtrace.h>
|
|
#endif
|
|
|
|
class TraceMgr : public a8::Singleton<TraceMgr>
|
|
{
|
|
|
|
private:
|
|
TraceMgr() {};
|
|
friend class a8::Singleton<TraceMgr>;
|
|
|
|
public:
|
|
|
|
void Init(const std::string& filename);
|
|
void UnInit();
|
|
|
|
void Trace(const std::string& hint);
|
|
std::string GetBackTrace();
|
|
|
|
private:
|
|
std::string filename_;
|
|
#if __GNUC__ > 4
|
|
backtrace_state* state_ = nullptr;
|
|
#endif
|
|
FILE* log_file_ = nullptr;
|
|
};
|
|
|
|
#endif
|