mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
Merge pull request #537 from NotAdam/develop
override StackWalker OnOutput to write to output using our logger util
This commit is contained in:
commit
90b440d228
3 changed files with 16 additions and 13 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "fatal", "off" }
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <spdlog/async.h>
|
#include <spdlog/async.h>
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
|
@ -10,16 +12,6 @@
|
||||||
|
|
||||||
namespace fs = std::experimental::filesystem;
|
namespace fs = std::experimental::filesystem;
|
||||||
|
|
||||||
Sapphire::Logger::Logger()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Sapphire::Logger::~Logger()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sapphire::Logger::init( const std::string& logPath )
|
void Sapphire::Logger::init( const std::string& logPath )
|
||||||
{
|
{
|
||||||
auto pos = logPath.find_last_of( fs::path::preferred_separator );
|
auto pos = logPath.find_last_of( fs::path::preferred_separator );
|
||||||
|
|
|
@ -13,8 +13,8 @@ namespace Sapphire
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_logFile;
|
std::string m_logFile;
|
||||||
Logger();
|
Logger() = default;
|
||||||
~Logger();
|
~Logger() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,17 @@
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
#else
|
#else
|
||||||
#include <stackwalker/StackWalker.h>
|
#include <stackwalker/StackWalker.h>
|
||||||
|
|
||||||
|
class SapphireStackWalker : public StackWalker
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SapphireStackWalker() : StackWalker() {}
|
||||||
|
protected:
|
||||||
|
virtual void OnOutput( LPCSTR szText )
|
||||||
|
{
|
||||||
|
Sapphire::Logger::fatal( "{}", szText );
|
||||||
|
}
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
|
@ -137,7 +148,7 @@ void Util::CrashHandler::printStackTrace( unsigned int max_frames )
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
StackWalker sw;
|
SapphireStackWalker sw;
|
||||||
sw.ShowCallstack();
|
sw.ShowCallstack();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue