From 3d2fb21d0e93b6b595610285e910ac80c099a174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Gehring?= Date: Tue, 28 Jul 2015 06:46:54 -0700 Subject: CommonAPI 3.1.3 --- src/CommonAPI/Logger.cpp | 11 +++++++++-- src/CommonAPI/Runtime.cpp | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/CommonAPI/Logger.cpp b/src/CommonAPI/Logger.cpp index 4514bd7..f7e2de3 100644 --- a/src/CommonAPI/Logger.cpp +++ b/src/CommonAPI/Logger.cpp @@ -39,6 +39,13 @@ Logger::Logger() { #endif } +Logger::~Logger() { +#ifdef USE_DLT + DLT_UNREGISTER_CONTEXT(dlt_); + DLT_UNREGISTER_APP(); +#endif +} + void Logger::init(bool _useConsole, const std::string &_fileName, bool _useDlt, const std::string &_level) { #ifdef USE_CONSOLE @@ -63,13 +70,13 @@ void Logger::doLog(Level _level, const std::string &_message) { #ifdef USE_CONSOLE if (useConsole_) { - std::lock_guard consoleGuard(mutex_); + std::lock_guard itsLock(mutex_); std::cout << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl; } #endif #ifdef USE_FILE if (file_ && file_->is_open()) { - std::lock_guard consoleGuard(mutex_); + std::lock_guard itsLock(mutex_); (*(file_.get())) << "[CAPI][" << levelAsString(_level) << "] " << _message << std::endl; } #endif diff --git a/src/CommonAPI/Runtime.cpp b/src/CommonAPI/Runtime.cpp index 74c2c0f..9cd73eb 100644 --- a/src/CommonAPI/Runtime.cpp +++ b/src/CommonAPI/Runtime.cpp @@ -153,6 +153,11 @@ Runtime::readConfiguration() { if (!reader.load(config)) return false; + std::string itsConsole("true"); + std::string itsFile; + std::string itsDlt("false"); + std::string itsLevel("info"); + std::shared_ptr section = reader.getSection("logging"); if (section) { @@ -160,13 +165,13 @@ Runtime::readConfiguration() { std::string itsFile = section->getValue("file"); std::string itsDlt = section->getValue("dlt"); std::string itsLevel = section->getValue("level"); - - Logger::init((itsConsole == "true"), - itsFile, - (itsDlt == "true"), - itsLevel); } + Logger::init((itsConsole == "true"), + itsFile, + (itsDlt == "true"), + itsLevel); + section = reader.getSection("default"); if (section) { std::string binding = section->getValue("binding"); @@ -298,7 +303,11 @@ Runtime::getLibrary( // name. library = getProperty("LibraryBase"); if (library != "") { +#ifdef WIN32 + library = library + "-" + defaultBinding_; +#else library = "lib" + library + "-" + defaultBinding_; +#endif } else { library = "lib" + _domain + "__" + _interface + "__" + _instance; std::replace(library.begin(), library.end(), '.', '_'); -- cgit v1.2.1