diff --git a/CMakeLists.txt b/CMakeLists.txt index 1df514dc1..08713be90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,10 @@ if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) endif() endif() -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.11) + +cmake_policy(VERSION 2.8.11.2013-0628-g46c95) +cmake_policy(SET CMP0022 NEW) project(swganh CXX) @@ -156,14 +159,10 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") - ADD_DEFINITIONS (/D BOOST_ALL_DYN_LINK) - MESSAGE(STATUS "- BOOST: Enable dynamic linking") - - ADD_DEFINITIONS (/D _HAS_ITERATOR_DEBUGGING=0) - MESSAGE(STATUS "- MSVC: set iterator debugging to 0") - ADD_DEFINITIONS (/D _SECURE_SCL=0) MESSAGE(STATUS "- MSVC: set iterator debugging to 0") + + add_definitions(-DHAVE_ROUND) endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_WARNINGS}") @@ -171,6 +170,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNINGS}") # Use the static/multithreaded libraries. add_definitions(-DBOOST_ALL_NO_LIB) +add_definitions(-DBOOST_ALL_DYN_LINK) set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) diff --git a/build_deps.bat b/build_deps.bat index fff5000f5..6540dd254 100644 --- a/build_deps.bat +++ b/build_deps.bat @@ -36,8 +36,8 @@ set "PROJECT_BASE=%~dp0" set "PROJECT_DRIVE=%~d0" set "BUILD_DIR=%PROJECT_BASE%build\deps\" set "VENDOR_DIR=%PROJECT_BASE%vendor\" -set MSVC_VERSION=11 -set BOOST_VERSION=1.53.0 +set MSVC_VERSION=12 +set BOOST_VERSION=1.54.0 set BOOST_LOG_REVISION=737 set TURTLE_VERSION=1.2.0 set GLM_VERSION=0.9.4.1 @@ -131,12 +131,12 @@ call where git /Q | findstr /c:"git.exe" >nul && ( exit /b 1 ) -if not exist "%VS110COMNTOOLS%" ( - echo ***** Microsoft Visual Studio 11 required ***** +if not exist "!VS%MSVC_VERSION%0COMNTOOLS!" ( + echo ***** Microsoft Visual Studio %MSVC_VERSION% required ***** exit /b 1 ) -call "%VS110COMNTOOLS%\vsvars32.bat" >NUL +call "!VS%MSVC_VERSION%0COMNTOOLS!\vsvars32.bat" >NUL set environment_built=yes @@ -156,21 +156,12 @@ set BOOST_FILE=boost_%BOOST_VERSION_ALT%.zip set BOOST_URL=http://downloads.sourceforge.net/project/boost/boost/%BOOST_VERSION%/%BOOST_FILE% set BOOST_DIR=boost_%BOOST_VERSION_ALT% -if not exist %BOOST_FILE% ( - %WGET% --no-check-certificate !BOOST_URL! -) - if not exist %BOOST_DIR% ( - %ZIP% x -y %BOOST_FILE% -) - -if not exist boost-log ( - git svn clone -r %BOOST_LOG_REVISION% https://boost-log.svn.sourceforge.net/svnroot/boost-log/trunk/boost-log -) + if not exist %BOOST_FILE% ( + %WGET% --no-check-certificate !BOOST_URL! + ) -if not exist "%BOOST_DIR%\boost\log" ( - xcopy "boost-log/boost/log" "%BOOST_DIR%/boost/log" /s /i /y - xcopy "boost-log/libs/log" "%BOOST_DIR%/libs/log" /s /i /y + %ZIP% x -y %BOOST_FILE% ) cd "%BOOST_DIR%" @@ -179,7 +170,7 @@ if not exist b2.exe ( cmd /c bootstrap.bat ) -cmd /c "b2.exe" --toolset=msvc-%MSVC_VERSION%.0 --with-serialization --with-iostreams --with-program_options --with-system --with-thread --with-filesystem --with-log --with-python --with-test --with-date_time variant=debug,release link=shared runtime-link=shared threading=multi define=_SCL_SECURE_NO_WARNINGS=0 define=_ITERATOR_DEBUG_LEVEL=0 +cmd /c "b2.exe" --toolset=msvc-%MSVC_VERSION%.0 --with-serialization --with-iostreams --with-program_options --with-system --with-thread --with-filesystem --with-log --with-python --with-test --with-date_time variant=debug,release link=shared runtime-link=shared threading=multi define=HAVE_ROUND define=_SCL_SECURE_NO_WARNINGS=0 if not exist %VENDOR_DIR%include\boost ( xcopy "boost" "%VENDOR_DIR%include\boost" /s /i /y @@ -268,7 +259,7 @@ if not exist "%ZLIB_DIR%" ( cd "%ZLIB_DIR%" -cmake -G"Visual Studio 11" . +cmake -G"Visual Studio %MSVC_VERSION%" . cmake --build . --target zlib --config Debug cmake --build . --target zlib --config Release @@ -320,11 +311,11 @@ if not exist "%MYSQL_C_DIR%" ( cd "%MYSQL_C_DIR%" -cmake -G"Visual Studio 11" . -cmake --build . --target mysqlclient --config Debug -cmake --build . --target libmysql --config Debug -cmake --build . --target mysqlclient --config Release -cmake --build . --target libmysql --config Release +cmake -G"Visual Studio %MSVC_VERSION%" . +cmake --build . --target libmysql/mysqlclient --config Debug +cmake --build . --target libmysql/libmysql --config Debug +cmake --build . --target libmysql/mysqlclient --config Release +cmake --build . --target libmysql/libmysql --config Release if not exist "%VENDOR_DIR%include\mysql.h" ( xcopy "include" "%VENDOR_DIR%include" /s /i /y @@ -351,9 +342,9 @@ if not exist mysql-connector-cpp ( cd mysql-connector-cpp -cmake -G"Visual Studio 11" -DDISABLE_ITERATOR_DEBUGGING=ON -DBOOST_ROOT=%VENDOR_DIR% -DMYSQL_INCLUDE_DIR=%VENDOR_DIR%include -DMYSQL_LIB_DIR=%VENDOR_DIR%lib/Release . -cmake --build . --target mysqlcppconn --config Debug -cmake --build . --target mysqlcppconn --config Release +cmake -G"Visual Studio %MSVC_VERSION%" -DBOOST_ROOT=%VENDOR_DIR% -DMYSQL_INCLUDE_DIR=%VENDOR_DIR%include -DMYSQL_LIB_DIR=%VENDOR_DIR%lib/Release . +cmake --build . --target driver/mysqlcppconn --config Debug +cmake --build . --target driver/mysqlcppconn --config Release if not exist "%VENDOR_DIR%include\cppconn" ( xcopy "cppconn" "%VENDOR_DIR%include\cppconn" /s /i /y diff --git a/src/swganh/CMakeLists.txt b/src/swganh/CMakeLists.txt index 510caa41e..8f2a601b0 100644 --- a/src/swganh/CMakeLists.txt +++ b/src/swganh/CMakeLists.txt @@ -21,8 +21,8 @@ AddANHExecutable(swganh ${PYTHON_LIBRARY} ${Boost_CHRONO_LIBRARY_DEBUG} ${Boost_DATE_TIME_LIBRARY_DEBUG} - ${Boost_LOG_LIBRARY_DEBUG} ${Boost_LOG_SETUP_LIBRARY_DEBUG} + ${Boost_LOG_LIBRARY_DEBUG} ${Boost_FILESYSTEM_LIBRARY_DEBUG} ${Boost_PROGRAM_OPTIONS_LIBRARY_DEBUG} ${Boost_PYTHON3_LIBRARY_DEBUG} @@ -39,8 +39,8 @@ AddANHExecutable(swganh ${PYTHON_LIBRARY} ${Boost_CHRONO_LIBRARY_RELEASE} ${Boost_DATE_TIME_LIBRARY_RELEASE} - ${Boost_LOG_LIBRARY_RELEASE} ${Boost_LOG_SETUP_LIBRARY_RELEASE} + ${Boost_LOG_LIBRARY_RELEASE} ${Boost_FILESYSTEM_LIBRARY_RELEASE} ${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} ${Boost_PYTHON3_LIBRARY_RELEASE} diff --git a/src/swganh/app/CMakeLists.txt b/src/swganh/app/CMakeLists.txt index e10e5862a..bb0a63269 100644 --- a/src/swganh/app/CMakeLists.txt +++ b/src/swganh/app/CMakeLists.txt @@ -16,6 +16,7 @@ AddANHPythonBinding(app DEBUG_LIBRARIES ${Boost_CHRONO_LIBRARY_DEBUG} ${Boost_DATE_TIME_LIBRARY_DEBUG} + ${Boost_LOG_SETUP_LIBRARY_DEBUG} ${Boost_LOG_LIBRARY_DEBUG} ${Boost_FILESYSTEM_LIBRARY_DEBUG} ${Boost_PROGRAM_OPTIONS_LIBRARY_DEBUG} @@ -31,6 +32,7 @@ AddANHPythonBinding(app OPTIMIZED_LIBRARIES ${Boost_CHRONO_LIBRARY_RELEASE} ${Boost_DATE_TIME_LIBRARY_RELEASE} + ${Boost_LOG_SETUP_LIBRARY_RELEASE} ${Boost_LOG_LIBRARY_RELEASE} ${Boost_FILESYSTEM_LIBRARY_RELEASE} ${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE} diff --git a/src/swganh/app/swganh_app.cc b/src/swganh/app/swganh_app.cc index c78357afd..d2da84ea6 100644 --- a/src/swganh/app/swganh_app.cc +++ b/src/swganh/app/swganh_app.cc @@ -74,10 +74,10 @@ options_description AppConfig::BuildConfigDescription() { ("galaxy_name", boost::program_options::value(&galaxy_name), "Name of the galaxy (cluster) to this process should run") - + ("resource_cache_size", boost::program_options::value(&resource_cache_size), "Available cache size for the resource manager (in Megabytes)") - + ("io_threads", value(&io_threads)->default_value(boost::thread::hardware_concurrency()), "Total number of threads to allocate for io management.") @@ -107,7 +107,7 @@ options_description AppConfig::BuildConfigDescription() { "Username for authentication with the galaxy datastore") ("db.galaxy.password", boost::program_options::value(&galaxy_db.password), "Password for authentication with the galaxy datastore") - + ("db.swganh_static.host", boost::program_options::value(&swganh_static_db.host), "Host address for the swganh_static datastore") ("db.swganh_static.schema", boost::program_options::value(&swganh_static_db.schema), @@ -117,22 +117,22 @@ options_description AppConfig::BuildConfigDescription() { ("db.swganh_static.password", boost::program_options::value(&swganh_static_db.password), "Password for authentication with the swganh_static datastore") - ("service.login.udp_port", + ("service.login.udp_port", boost::program_options::value(&login_config.listen_port), "The port the login service will listen for incoming client connections on") - ("service.login.address", + ("service.login.address", boost::program_options::value(&login_config.listen_address), "The public address the login service will listen for incoming client connections on") - ("service.login.status_check_duration_secs", + ("service.login.status_check_duration_secs", boost::program_options::value(&login_config.galaxy_status_check_duration_secs), "The amount of time between checks for updated galaxy status") - ("service.login.login_error_timeout_secs", + ("service.login.login_error_timeout_secs", boost::program_options::value(&login_config.login_error_timeout_secs)->default_value(5), "The number of seconds to wait before disconnecting a client after failed login attempt") ("service.login.auto_registration", boost::program_options::value(&login_config.login_auto_registration)->default_value(false), "Auto Registration flag") - + ("service.connection.ping_port", boost::program_options::value(&connection_config.ping_port), "The port the connection service will listen for incoming client ping requests on") ("service.connection.udp_port", boost::program_options::value(&connection_config.listen_port), @@ -140,7 +140,7 @@ options_description AppConfig::BuildConfigDescription() { ("service.connection.address", boost::program_options::value(&connection_config.listen_address), "The public address the connection service will listen for incoming client connections on") - + ("service.simulation.scene", boost::program_options::value>(&scenes), "Loads the specified scene, can have multiple scenes") ; @@ -162,7 +162,7 @@ SwganhApp::SwganhApp(int argc, char* argv[]) Start(); } -SwganhApp::~SwganhApp() +SwganhApp::~SwganhApp() { Stop(); // Shutdown Event Dispatcher @@ -170,7 +170,7 @@ SwganhApp::~SwganhApp() io_work_.reset(); cpu_work_.reset(); - + // join the threadpool threads until each one has exited. for_each(io_threads_.begin(), io_threads_.end(), std::mem_fn(&std::thread::join)); for_each(cpu_threads_.begin(), cpu_threads_.end(), std::mem_fn(&std::thread::join)); @@ -181,7 +181,7 @@ SwganhApp::~SwganhApp() void SwganhApp::Initialize(int argc, char* argv[]) { // Init Logging SetupLogging_(); - + std::cout << "Ben Kenobi : That boy was our last hope." << std::endl; std::cout << " Yoda : No! There is another..." << std::endl << std::endl; std::cout << " .d8888b. 888 888 .d8888b. d8888 888b 888 888 888 " << std::endl; @@ -193,30 +193,30 @@ void SwganhApp::Initialize(int argc, char* argv[]) { std::cout << "Y88b d88P 8888P Y8888 Y88b d88P d8888888888 888 Y8888 888 888 " << std::endl; std::cout << " \"Y8888P\" 888P Y888 \"Y8888P88 d88P 888 888 Y888 888 888 " << std::endl << std::endl; std::cout << " Release " << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH << " "<< std::endl << std::endl << std::endl; - - - // Load the configuration + + + // Load the configuration LoadAppConfig_(argc, argv); auto app_config = kernel_->GetAppConfig(); try { - - // Initialize kernel resources + + // Initialize kernel resources kernel_->GetDatabaseManager()->registerStorageType( "galaxy_manager", app_config.galaxy_manager_db.schema, app_config.galaxy_manager_db.host, app_config.galaxy_manager_db.username, app_config.galaxy_manager_db.password); - + kernel_->GetDatabaseManager()->registerStorageType( "galaxy", app_config.galaxy_db.schema, app_config.galaxy_db.host, app_config.galaxy_db.username, app_config.galaxy_db.password); - + kernel_->GetDatabaseManager()->registerStorageType( "swganh_static", app_config.swganh_static_db.schema, @@ -224,15 +224,15 @@ void SwganhApp::Initialize(int argc, char* argv[]) { app_config.swganh_static_db.username, app_config.swganh_static_db.password); - } + } catch(std::exception& e) { LOG(fatal) << "Database connection errors occurred. Did you forget to populate the db?"; throw e; } - + CleanupServices_(); - + // append command dir std::string py_path = "import sys; sys.path.append('.'); sys.path.append('" + app_config.script_directory + "');"; { @@ -245,7 +245,7 @@ void SwganhApp::Initialize(int argc, char* argv[]) { // Load core services LoadCoreServices_(); - + initialized_ = true; } @@ -258,9 +258,9 @@ void SwganhApp::Start() { running_ = true; //Create a number of threads to pull packets off the wire. - for (uint32_t i = 0; i < kernel_->GetAppConfig().io_threads; ++i) + for (uint32_t i = 0; i < kernel_->GetAppConfig().io_threads; ++i) { - io_threads_.emplace_back([this] () + io_threads_.emplace_back([this] () { //Continue looping despite errors. //If we successfully leave the run method we return. @@ -270,8 +270,8 @@ void SwganhApp::Start() { { io_pool_.run(); return; - } - catch(...) + } + catch(...) { LOG(severity_level::error) << "A near fatal exception has occurred."; } @@ -289,21 +289,21 @@ void SwganhApp::Start() { { cpu_pool_.run(); return; - } - catch(...) + } + catch(...) { LOG(severity_level::error) << "A near fatal exception has occurred."; } } }); } - + kernel_->GetServiceManager()->Start(); kernel_->GetEventDispatcher()->Dispatch(std::make_shared("Core::ApplicationInitComplete")); //Now that services are started, start the scenes. //auto simulation_service = kernel_->GetServiceManager()->GetService("SimulationService"); - + //Ground Zones //simulation_service->StartScene("corellia"); //simulation_service->StartScene("dantooine"); @@ -326,13 +326,13 @@ void SwganhApp::Start() { //simulation_service->StartScene("space_naboo"); //simulation_service->StartScene("space_tatooine"); //simulation_service->StartScene("space_yavin4"); - + //Special //simulation_service->StartScene("tutorial"); } void SwganhApp::Stop() { - running_ = false; + running_ = false; } bool SwganhApp::IsRunning() { @@ -346,29 +346,29 @@ SwganhKernel* SwganhApp::GetAppKernel() const { void SwganhApp::StartInteractiveConsole() { swganh::scripting::ScopedGilLock lock; - swganh::Logger::getInstance().DisableConsoleLogging(); +// swganh::Logger::getInstance().DisableConsoleLogging(); #ifdef WIN32 std::system("cls"); #else if (std::system("clear") != 0) { - LOG(::error) << "Error clearing screen, ignoring console mode"; + LOG(warning) << "Error clearing screen, ignoring console mode"; return; } #endif std::cout << "swgpy console " << VERSION_MAJOR << "." << VERSION_MINOR << "." << VERSION_PATCH << std::endl; - + boost::python::object main = boost::python::object (boost::python::handle<>(boost::python::borrowed( PyImport_AddModule("__main__") ))); auto global_dict = main.attr("__dict__"); global_dict["kernel"] = boost::python::ptr(GetAppKernel()); - + PyRun_InteractiveLoop(stdin, ""); - - swganh::Logger::getInstance().EnableConsoleLogging(); + +// swganh::Logger::getInstance().EnableConsoleLogging(); } void SwganhApp::LoadAppConfig_(int argc, char* argv[]) { @@ -398,7 +398,7 @@ void SwganhApp::LoadAppConfig_(int argc, char* argv[]) { } } -void SwganhApp::LoadPlugins_(vector plugins) { +void SwganhApp::LoadPlugins_(vector plugins) { if (!plugins.empty()) { auto plugin_manager = kernel_->GetPluginManager(); auto plugin_directory = kernel_->GetAppConfig().plugin_directory; @@ -427,15 +427,15 @@ void SwganhApp::CleanupServices_() { }); } -void SwganhApp::LoadCoreServices_() +void SwganhApp::LoadCoreServices_() { - + auto plugin_manager = kernel_->GetPluginManager(); auto registration_map = plugin_manager->registration_map(); regex rx("(?:.*\\:\\:)(.*Service)"); smatch m; - + for_each(registration_map.begin(), registration_map.end(), [this, &rx, &m] (RegistrationMap::value_type& entry) { std::string name = entry.first; @@ -450,5 +450,5 @@ void SwganhApp::LoadCoreServices_() void SwganhApp::SetupLogging_() { - swganh::Logger::getInstance().init("swganh"); -} \ No newline at end of file +// swganh::Logger::getInstance().init("swganh"); +} diff --git a/src/swganh/logger.cpp b/src/swganh/logger.cpp index e161ccbaf..65ffedfae 100644 --- a/src/swganh/logger.cpp +++ b/src/swganh/logger.cpp @@ -3,85 +3,36 @@ #include "logger.h" -using namespace swganh; +#include -Logger& Logger::getInstance() +#include +#include +#include +#include +#include + +namespace swganh { + +logger::logger_type& logger::get() { - static Logger instance; - return instance; + return boost::log::sources::aux::logger_singleton::get(); } -void Logger::init(const std::string& app_name) +logger::logger_type logger::construct_logger() { - // Console Logs info and above - console_sink_ = logging::init_log_to_console( - std::clog, - keywords::filter = flt::attr("Severity", std::nothrow) >= info, - keywords::format = "%TimeStamp%: %_%", - keywords::auto_flush = true - ); -// If we're in debug mode compile debug and above -#ifdef _DEBUG - // Log Everything info and above to swganh.log - logging::init_log_to_file - ( - "logs/" + app_name + "_debug.log", - keywords::filter = flt::attr("Severity", std::nothrow) >= info, - keywords::format = fmt::format("%1% [%2%] <%3%> %4%") - % fmt::date_time("TimeStamp", std::nothrow) - % fmt::attr("Severity", std::nothrow) - % fmt::attr("ThreadID") - % fmt::message(), - keywords::auto_flush = true - ); + auto core = boost::log::core::get(); + auto backend = boost::make_shared(); -#else - // Log Everything info and above to swganh.log - logging::init_log_to_file - ( - "logs/" + app_name + ".log", - keywords::filter = flt::attr("Severity", std::nothrow) >= info, - keywords::format = fmt::format("%1% [%2%] <%3%> %4%") - % fmt::date_time("TimeStamp", std::nothrow) - % fmt::attr("Severity", std::nothrow) - % fmt::attr("ThreadID") - % fmt::message() - ); -#endif - // Log Everything warning and above to swganh.log - logging::init_log_to_file - ( - "logs/"+ app_name + "_warning.log", - keywords::filter = flt::attr("Severity", std::nothrow) >= warning, - keywords::format = fmt::format("%1% [%2%] <%3%> %4%") - % fmt::date_time("TimeStamp", std::nothrow) - % fmt::attr("Severity", std::nothrow) - % fmt::attr("ThreadID") - % fmt::message(), - keywords::auto_flush = true - ); - - // Log Client/Server messages - logging::init_log_to_file - ( - "logs/"+ app_name + "_events.log", - keywords::filter = flt::attr("Severity", std::nothrow) == event, - keywords::format = fmt::format("%1% <%2%> %3%") - % fmt::date_time("TimeStamp", std::nothrow) - % fmt::attr("ThreadID") - % fmt::message(), - keywords::auto_flush = true - ); - - logging::add_common_attributes(); -} + backend->add_stream(boost::shared_ptr(&std::clog, boost::log::empty_deleter())); + backend->add_stream(boost::make_shared("logs/swganh.log")); -void Logger::EnableConsoleLogging() -{ - logging::core::get()->add_sink(console_sink_); + backend->auto_flush(true); + + auto sink = boost::make_shared>(backend); + + core->add_sink(sink); + + return logger_type(); } -void Logger::DisableConsoleLogging() -{ - logging::core::get()->remove_sink(console_sink_); } diff --git a/src/swganh/logger.h b/src/swganh/logger.h index d67f80a5b..1ca751ee4 100644 --- a/src/swganh/logger.h +++ b/src/swganh/logger.h @@ -2,111 +2,64 @@ // See file LICENSE or go to http://swganh.com/LICENSE #pragma once -// LOG -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// - +#include +#include +#include +#include +#include -namespace logging = boost::log; -namespace attrs = boost::log::attributes; -namespace src = boost::log::sources; -namespace sinks = boost::log::sinks; -namespace fmt = boost::log::formatters; -namespace flt = boost::log::filters; -namespace keywords = boost::log::keywords; +namespace swganh { enum severity_level { - event, - info, - warning, - error, - fatal + event, + info, + warning, + error, + fatal }; -// The formatting logic for the severity level -template< typename CharT, typename TraitsT > -inline std::basic_ostream< CharT, TraitsT >& operator<< ( -std::basic_ostream< CharT, TraitsT >& strm, severity_level lvl) + +template +inline std::basic_ostream& operator<<( + std::basic_ostream& stream, ::swganh::severity_level level) { - static const char* const str[] = - { - "event", - "info", - "warning", - "error", - "fatal" - }; - if (static_cast< std::size_t >(lvl) < (sizeof(str) / sizeof(*str))) - strm << str[lvl]; - else - strm << static_cast< int >(lvl); - return strm; + static const char* const str[] = + { + "event", + "info", + "warning", + "error", + "fatal" + }; + if (static_cast(level) < (sizeof(str) / sizeof(*str))) { + stream << str[level]; + } else { + stream << static_cast(level); + } + + return stream; } -static src::severity_logger SeverityLogger; +struct logger +{ + typedef boost::log::sources::severity_logger_mt<::swganh::severity_level> logger_type; -#define LOG(level) BOOST_LOG_STREAM_SEV(SeverityLogger, level) + static logger_type& get(); + static logger_type construct_logger(); -#ifdef _DEBUG -#define LOG_NET BOOST_LOG_STREAM_SEV(SeverityLogger, event) -#else -#define LOG_NET if (true);else LOG(event) -#endif + enum registration_line_t { registration_line = __LINE__ }; + static const char* registration_file() { return __FILE__; } +}; + +#define LOG(level)\ + BOOST_LOG_SEV(::swganh::logger::get(),\ + (::swganh::level)) #ifdef _DEBUG -#define DLOG(level) BOOST_LOG_STREAM_SEV(SeverityLogger, level) +#define DLOG(level) LOG(level) #else -#define DLOG(level) if (true);else LOG(level) +#define DLOG(level) if (true); else LOG(level) #endif -namespace swganh { - -/** - * A general boost.log initialization logging object - * - */ - -class Logger -{ -public: - static Logger &getInstance(); - /** - * Init's the logging sinks and formatters - * - * @param string of the application name - * two files are created in the logs folder of the application - * one is created as app_name.log containing severity level of info and above - * the other is created as app_name_warning.log containing severity level of warning and above - */ - void init(const std::string& app_name); - - void EnableConsoleLogging(); - - void DisableConsoleLogging(); - -private: - Logger() {} - ~Logger() {} - Logger(const Logger&); - Logger &operator=(const Logger &); - - typedef boost::shared_ptr< - boost::log::sinks::synchronous_sink< - boost::log::sinks::text_ostream_backend - >> console_sink_t; - - console_sink_t console_sink_; -}; - -} // anh +} // namespace swganh diff --git a/src/swganh/network/session.cc b/src/swganh/network/session.cc index 99a73acbc..8d8033b06 100644 --- a/src/swganh/network/session.cc +++ b/src/swganh/network/session.cc @@ -67,7 +67,7 @@ uint32_t Session::crc_seed() const { swganh::ByteBuffer Session::SendSoePacket_(swganh::ByteBuffer message) { - LOG_NET << "S->C: " << server_->listen_endpoint() << " -> " << remote_endpoint() << "\n" << message; +// LOG_NET << "S->C: " << server_->listen_endpoint() << " -> " << remote_endpoint() << "\n" << message; compression_filter_(this, &message); encryption_filter_(this, &message); @@ -212,7 +212,7 @@ void Session::HandleProtocolMessageInternal(swganh::ByteBuffer message) decompression_filter_(this, &message); } - LOG_NET << "C->S: " << remote_endpoint() << " -> " << server_->listen_endpoint() << "\n" << message; +// LOG_NET << "C->S: " << remote_endpoint() << " -> " << server_->listen_endpoint() << "\n" << message; if(message.peek() != 0) { server_->HandleMessage(shared_from_this(), std::move(message)); diff --git a/src/swganh/service/datastore.cc b/src/swganh/service/datastore.cc index be48ee99f..57a534647 100644 --- a/src/swganh/service/datastore.cc +++ b/src/swganh/service/datastore.cc @@ -1,4 +1,4 @@ -// This file is part of SWGANH which is released under the MIT license. + // This file is part of SWGANH which is released under the MIT license. // See file LICENSE or go to http://swganh.com/LICENSE #include "swganh/service/datastore.h" @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/src/swganh_core/chat/mysql_chat_user_provider.cc b/src/swganh_core/chat/mysql_chat_user_provider.cc index acf97d057..8344e5a10 100644 --- a/src/swganh_core/chat/mysql_chat_user_provider.cc +++ b/src/swganh_core/chat/mysql_chat_user_provider.cc @@ -1,4 +1,5 @@ #include +#include #include #include "mysql_chat_user_provider.h"