#include #include #include #include #include #include #include static auto _createSinks() { std::vector< spdlog::sink_ptr > sinks; auto stdout_sink = spdlog::sinks::stdout_sink_mt::instance(); sinks.emplace_back(std::make_shared< spdlog::sinks::ansicolor_sink >(stdout_sink)); sinks.emplace_back(std::make_shared< spdlog::sinks::daily_file_sink_st >("logfile", 23, 59)); return sinks; } static void initializeLogs() { std::vector< spdlog::sink_ptr > sinks = _createSinks(); auto combined_logger = std::make_shared< spdlog::logger >("default", begin(sinks), end(sinks)); combined_logger->set_level(spdlog::level::trace); spdlog::register_logger(combined_logger); } static auto createDbConnection(std::function< bool(const std::string &, std::string &) > propRead) { using std::make_unique; using std::move; using std::unique_ptr; auto dbConfig = make_unique< eedb::pg::Config >(propRead); try { return make_unique< eedb::pg::Connection >(std::move(dbConfig)); } catch(const sqlpp::postgresql::broken_connection & e) { std::cout << "sql exception: " << e.what(); // return std::make_unique< ErrorWindow >(env) } } std::unique_ptr< Wt::WApplication > createApplication(const Wt::WEnvironment & env) { auto server = env.server(); auto connection = createDbConnection([server](const auto & name, auto & val) { // return server->readConfigurationProperty(name, val); }); auto factory = std::make_unique< eedb::pg::FactoryImpl >(std::move(connection)); return eedb::WebApplicationFactory{}.create(std::move(factory), env); } int main(int argc, char ** argv) { initializeLogs(); eedb::WebServer server{argc, argv}; server.run(createApplication); return 0; }