mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
fix build errors, add new json dep
This commit is contained in:
parent
53bab1f780
commit
3e62c7653b
4 changed files with 19446 additions and 10 deletions
19430
deps/nlohmann/json.hpp
vendored
Normal file
19430
deps/nlohmann/json.hpp
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,5 @@
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
#include <spdlog/sinks/daily_file_sink.h>
|
#include <spdlog/sinks/daily_file_sink.h>
|
||||||
|
|
||||||
|
@ -26,20 +25,22 @@ void Logger::setLogPath( const std::string& logPath )
|
||||||
|
|
||||||
void Logger::init()
|
void Logger::init()
|
||||||
{
|
{
|
||||||
|
spdlog::init_thread_pool( 8192, 1 );
|
||||||
|
|
||||||
std::vector< spdlog::sink_ptr > sinks;
|
auto stdout_sink = std::make_shared< spdlog::sinks::stdout_color_sink_mt >();
|
||||||
|
auto daily_sink = std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile + ".log", 0, 0 );
|
||||||
|
|
||||||
sinks.push_back( std::make_shared< spdlog::sinks::stdout_color_sink_mt >() );
|
std::vector<spdlog::sink_ptr> sinks { stdout_sink, daily_sink };
|
||||||
sinks.push_back( std::make_shared< spdlog::sinks::daily_file_sink_mt >( m_logFile + ".log", 0, 0 ) );
|
|
||||||
|
auto logger = std::make_shared< spdlog::async_logger >( "logger", sinks.begin(), sinks.end(), spdlog::thread_pool(), spdlog::async_overflow_policy::block );
|
||||||
|
|
||||||
|
spdlog::register_logger( logger );
|
||||||
|
spdlog::set_pattern( "[%H:%M:%S.%e] [%^%l%$] %v" );
|
||||||
|
|
||||||
m_logger = std::make_shared< spdlog::logger >( "logger", std::begin( sinks ), std::end( sinks ) );
|
|
||||||
spdlog::register_logger(m_logger);
|
|
||||||
// always flush the log on criticial messages, otherwise it's done by libc
|
// always flush the log on criticial messages, otherwise it's done by libc
|
||||||
// see: https://github.com/gabime/spdlog/wiki/7.-Flush-policy
|
// see: https://github.com/gabime/spdlog/wiki/7.-Flush-policy
|
||||||
// nb: if the server crashes, log data can be missing from the file unless something logs critical just before it does
|
// nb: if the server crashes, log data can be missing from the file unless something logs critical just before it does
|
||||||
m_logger->flush_on( spdlog::level::critical );
|
spdlog::flush_on( spdlog::level::critical );
|
||||||
|
|
||||||
spdlog::set_pattern( "[%H:%M:%S] [%l] %v" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _LOGGER_H
|
#define _LOGGER_H
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <spdlog/async.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <Database/DatabaseDef.h>
|
#include <Database/DatabaseDef.h>
|
||||||
|
|
||||||
Core::Network::SapphireAPI::SapphireAPI()
|
Core::Network::SapphireAPI::SapphireAPI()
|
||||||
|
@ -122,6 +124,8 @@ Core::Network::SapphireAPI::createCharacter( const int& accountId, const std::st
|
||||||
|
|
||||||
boost::property_tree::ptree pt;
|
boost::property_tree::ptree pt;
|
||||||
|
|
||||||
|
auto json = nlohmann::json::parse( infoJson );
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << infoJson;
|
ss << infoJson;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue