aboutsummaryrefslogtreecommitdiffstats
path: root/src/init.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-02-16 17:46:37 +0000
committerSaturneric <[email protected]>2023-02-16 17:46:37 +0000
commitd9142776de351c8a383ea85865293a2bd2add573 (patch)
treee94ce97e62e214a3114e0b0e140b5782dd576766 /src/init.cpp
parentfix: solve build problem on windows platform (diff)
downloadGpgFrontend-d9142776de351c8a383ea85865293a2bd2add573.tar.gz
GpgFrontend-d9142776de351c8a383ea85865293a2bd2add573.zip
fix: solve logging framework issues on windows
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 6aa2084e..6109fa47 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -37,6 +37,19 @@
#include "GpgFrontendBuildInfo.h"
#include "core/function/GlobalSettingStation.h"
+#ifdef WINDOWS
+int setenv(const char *name, const char *value, int overwrite)
+{
+ int errcode = 0;
+ if(!overwrite) {
+ size_t envsize = 0;
+ errcode = getenv_s(&envsize, NULL, 0, name);
+ if(errcode || envsize) return errcode;
+ }
+ return _putenv_s(name, value);
+}
+#endif
+
void init_logging_system() {
using namespace boost::posix_time;
using namespace boost::gregorian;
@@ -68,6 +81,15 @@ void init_logging_system() {
spdlog::set_default_logger(main_logger);
}
+void shutdown_logging_system() {
+#ifdef WINDOWS
+ // Under VisualStudio, this must be called before main finishes to workaround
+ // a known VS issue
+ spdlog::drop_all();
+ spdlog::shutdown();
+#endif
+}
+
void init_global_path_env() {
auto& settings =
GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();