From 9fb2e116c47a9d4e2866d34450d12dcb90d4a26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 12 Jul 2016 01:15:34 +0200 Subject: Move reload.*pp from louloulibs to src --- CMakeLists.txt | 7 +++++++ louloulibs/utils/reload.cpp | 28 ---------------------------- louloulibs/utils/reload.hpp | 4 ---- src/utils/reload.cpp | 28 ++++++++++++++++++++++++++++ src/utils/reload.hpp | 4 ++++ 5 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 louloulibs/utils/reload.cpp delete mode 100644 louloulibs/utils/reload.hpp create mode 100644 src/utils/reload.cpp create mode 100644 src/utils/reload.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 132e353..06733bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,13 @@ if(CARES_FOUND) include_directories(${CARES_INCLUDE_DIRS}) endif() +# +## utils +# +file(GLOB source_utils + src/utils/*.[hc]pp) +target_sources(utils PUBLIC ${source_utils}) + # ## irclib # diff --git a/louloulibs/utils/reload.cpp b/louloulibs/utils/reload.cpp deleted file mode 100644 index 7125a75..0000000 --- a/louloulibs/utils/reload.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include -#include -#include - -void open_database() -{ - const auto db_filename = Config::get("db_name", xdg_data_path("biboumi.sqlite")); - log_info("Opening database: ", db_filename); - Database::open(db_filename); - log_info("database successfully opened."); -} - -void reload_process() -{ - Config::read_conf(); - // Destroy the logger instance, to be recreated the next time a log - // line needs to be written - Logger::instance().reset(); - log_info("Configuration and logger reloaded."); - try { - open_database(); - } catch (const litesql::DatabaseError&) { - log_warning("Re-using the previous database."); - } -} - diff --git a/louloulibs/utils/reload.hpp b/louloulibs/utils/reload.hpp deleted file mode 100644 index 408426a..0000000 --- a/louloulibs/utils/reload.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -void open_database(); -void reload_process(); diff --git a/src/utils/reload.cpp b/src/utils/reload.cpp new file mode 100644 index 0000000..7125a75 --- /dev/null +++ b/src/utils/reload.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include + +void open_database() +{ + const auto db_filename = Config::get("db_name", xdg_data_path("biboumi.sqlite")); + log_info("Opening database: ", db_filename); + Database::open(db_filename); + log_info("database successfully opened."); +} + +void reload_process() +{ + Config::read_conf(); + // Destroy the logger instance, to be recreated the next time a log + // line needs to be written + Logger::instance().reset(); + log_info("Configuration and logger reloaded."); + try { + open_database(); + } catch (const litesql::DatabaseError&) { + log_warning("Re-using the previous database."); + } +} + diff --git a/src/utils/reload.hpp b/src/utils/reload.hpp new file mode 100644 index 0000000..408426a --- /dev/null +++ b/src/utils/reload.hpp @@ -0,0 +1,4 @@ +#pragma once + +void open_database(); +void reload_process(); -- cgit v1.2.3