int GameClientApp::main() { Trace("Game start"); std::ofstream logFile("log.txt"); FileFormatter fileFormatter; core::logging::Sink fileSink(core::logging::g_globalManager, logFile, core::util::BitSet< LL >() | LL::Error | LL::Info | LL::Trace | LL::Warning | LL::User1 | LL::User2 | LL::User3 | LL::User4, fileFormatter); game::Settings settings; if (!appshared::parseProtoFromFile("./data/client_settings.pb", settings)) { Log(LL::Warning) << "Missing or corrupt game_settings.pb in runtime directory. " << "Game may fail." << std::endl; #if FISHY_DEBUG settings = game::Settings::Builder(settings) .set_login_server(core::net::ServerDef::Builder() .set_connection_timeout_sec(60) .set_dns_name("localhost") .set_port(12002) .set_max_connections(20) .build()) .build(); #endif } volatile bool active = true; volatile bool hidden = false; core::window::Window window; core::input::InputManager inputManager; if (!settings.has_window_settings()) { const game::WindowSettings &windowSettings = settings.get_window_settings(); core::window::DisplayCaps displaySettings = window.getSettings(); displaySettings.m_fullScreen = windowSettings.has_fullscreen() ? windowSettings.get_fullscreen() : false; displaySettings.m_width = windowSettings.has_width() ? static_cast<u32>(windowSettings.get_width()) : 1024u; displaySettings.m_height = windowSettings.has_height() ? static_cast<u32>(windowSettings.get_height()) : 640u; displaySettings.m_lockCursor = windowSettings.has_lock_cursor() ? windowSettings.get_lock_cursor() : false; displaySettings.m_hideCursor = windowSettings.has_hide_cursor() ? windowSettings.get_hide_cursor() : false; window.setSettings(displaySettings); } Callbacks cbs(active, hidden, inputManager, window); window.setCallbackInterface(&cbs); window.setTitle("Silent Star"); window.create(); GameLoop loop(active, hidden, settings, inputManager, window); loop.run(); window.destroy(); core::logging::g_globalManager.unregisterSink(fileSink); return eExitCode::OK; }
void DefaultLoggingConfig( const char* processName ) { // Start by stripping out all the existing sinks. There should only be the startup console and file anyway. boost::log::core::get()->remove_all_sinks(); // Create the console sinks boost::shared_ptr<LoggingSink> consoleSink = boost::log::add_console_log(); // Create the fileSink. Use the process name with a counting suffix and a simple roll every 1MB rule. boost::shared_ptr<FileSink> fileSink( new FileSink( boost::log::keywords::file_name = std::string( processName ) + "_%N.log", boost::log::keywords::rotation_size = 1048576 )); // Create the default formatter and assign it to both sinks boost::log::formatter formatter = boost::log::expressions::stream << boost::log::expressions::attr< unsigned int >("LineID") << ": " << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S") << " " << boost::log::expressions::attr< std::string >( "Channel" ) << Severity << boost::log::expressions::message; consoleSink->set_formatter( formatter ); consoleSink->locked_backend()->auto_flush( true ); fileSink->set_formatter( formatter ); fileSink->locked_backend()->auto_flush( true ); // Default to only warnings and above. boost::log::core::get()->set_filter( Severity >= LoggingSeverityLevels::warning ); // Add the common attributes boost::log::add_common_attributes(); // Output a warning message that the logging was not configured Logger( "DefaultLoggingConfig" ).WarningStream() << "No logging configuration specified. Default logging config used." << std::endl; }
int GameServerApp::main() { std::ofstream logFile("server_log.pb", std::ios::binary | std::ios::out); core::logging::ProtoFileFormatter fileFormatter; core::logging::Sink fileSink(core::logging::g_globalManager, logFile, core::util::BitSet< LL >() | LL::Error | LL::Info | LL::Trace | LL::Warning | LL::User1 | LL::User2 | LL::User3 | LL::User4, fileFormatter); Trace("Game start"); game::Settings settings; if (!appshared::parseProtoFromFile("./data/server_settings.pb.txt", settings)) { settings = game::Settings::Builder(settings) .set_hosting_config(core::net::ServerDef::Builder() .set_connection_timeout_sec(60) .set_dns_name("localhost") .set_port(12001) .set_max_connections(20) .build()) .build(); appshared::printProtoToFile("./data/server_settings.pb.txt", settings); } GameLoop().run(settings); return eExitCode::OK; }