summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Keeler <jacob.keeler@livioradio.com>2016-08-08 11:05:16 -0400
committerJacob Keeler <jacob.keeler@livioradio.com>2016-08-08 11:05:16 -0400
commit503e3330b506da83e80742219ef07f518b15d18d (patch)
tree90223ddade992f573cedcdef100cd4133bc829d9
parent0843cf4323fe0c177fb9b211357c6c35112e1147 (diff)
downloadsdl_core-hotfix/implement_logs_enabled_option.tar.gz
Implemented the LogsEnabled option and included testshotfix/implement_logs_enabled_option
-rw-r--r--src/appMain/main.cc5
-rw-r--r--src/components/config_profile/include/config_profile/profile.h6
-rw-r--r--src/components/config_profile/src/profile.cc17
-rw-r--r--src/components/config_profile/test/profile_test.cc5
-rw-r--r--src/components/config_profile/test/smartDeviceLink.ini1
-rw-r--r--src/components/config_profile/test/smartDeviceLink_test.ini1
-rw-r--r--src/components/include/utils/logger.h3
7 files changed, 38 insertions, 0 deletions
diff --git a/src/appMain/main.cc b/src/appMain/main.cc
index 2c14bfa3b6..63e819d062 100644
--- a/src/appMain/main.cc
+++ b/src/appMain/main.cc
@@ -150,6 +150,11 @@ int32_t main(int32_t argc, char** argv) {
profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
}
+ if (!profile::Profile::instance()->logs_enabled()) {
+ LOG4CXX_INFO(logger_, "Logging option is not enabled, disabling logger now");
+ DISABLE_LOGGER();
+ }
+
#ifdef __QNX__
if (profile::Profile::instance()->enable_policy()) {
if (!utils::System("./init_policy.sh").Execute(true)) {
diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h
index 6a43cafdd3..1a91554b0b 100644
--- a/src/components/config_profile/include/config_profile/profile.h
+++ b/src/components/config_profile/include/config_profile/profile.h
@@ -64,6 +64,11 @@ class Profile : public utils::Singleton<Profile> {
const std::string& sdl_version() const;
/**
+ * @brief Returns true if logging is enabled, otherwise false
+ */
+ bool logs_enabled() const;
+
+ /**
* @brief Returns true if HMI should be started, otherwise false
*/
bool launch_hmi() const;
@@ -625,6 +630,7 @@ class Profile : public utils::Singleton<Profile> {
private:
std::string sdl_version_;
+ bool logs_enabled_;
bool launch_hmi_;
#ifdef WEB_HMI
std::string link_to_web_hmi_;
diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc
index 700c52fff8..20961b92bb 100644
--- a/src/components/config_profile/src/profile.cc
+++ b/src/components/config_profile/src/profile.cc
@@ -74,6 +74,7 @@ const char* kSDL4Section = "SDL4";
const char* kResumptionSection = "Resumption";
const char* kSDLVersionKey = "SDLVersion";
+const char* kLogsEnabledKey = "LogsEnabled";
const char* kHmiCapabilitiesKey = "HMICapabilities";
const char* kPathToSnapshotKey = "PathToSnapshot";
const char* kPreloadedPTKey = "PreloadedPT";
@@ -242,6 +243,7 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "Profile")
Profile::Profile()
: sdl_version_(kDefaultSDLVersion),
+ logs_enabled_(true),
launch_hmi_(true),
#ifdef WEB_HMI
link_to_web_hmi_(kDefaultLinkToWebHMI),
@@ -333,6 +335,10 @@ const std::string& Profile::sdl_version() const {
return sdl_version_;
}
+bool Profile::logs_enabled() const {
+ return logs_enabled_;
+}
+
bool Profile::launch_hmi() const {
return launch_hmi_;
}
@@ -702,6 +708,17 @@ void Profile::UpdateValues() {
LOG_UPDATED_VALUE(sdl_version_, kSDLVersionKey, kMainSection);
+ // Logs Enabled Parameter
+ std::string logs_enabled;
+ if (ReadValue(&logs_enabled, kMainSection, kLogsEnabledKey) &&
+ 0 == strcmp("true", logs_enabled.c_str())) {
+ logs_enabled_ = true;
+ } else {
+ logs_enabled_ = false;
+ }
+
+ LOG_UPDATED_BOOL_VALUE(logs_enabled_, kLogsEnabledKey, kMainSection);
+
// Launch HMI parameter
std::string launch_value;
if (ReadValue(&launch_value, kHmiSection, kLaunchHMIKey) &&
diff --git a/src/components/config_profile/test/profile_test.cc b/src/components/config_profile/test/profile_test.cc
index 9d9eca755f..aec34d85f6 100644
--- a/src/components/config_profile/test/profile_test.cc
+++ b/src/components/config_profile/test/profile_test.cc
@@ -187,12 +187,14 @@ TEST_F(ProfileTest, UpdateIntValues) {
TEST_F(ProfileTest, UpdateBoolValues) {
// Default values
EXPECT_EQ("smartDeviceLink.ini", Profile::instance()->config_file_name());
+ EXPECT_TRUE(profile::Profile::instance()->logs_enabled());
EXPECT_TRUE(profile::Profile::instance()->launch_hmi());
EXPECT_FALSE(profile::Profile::instance()->enable_policy());
// Set config file
Profile::instance()->config_file_name("smartDeviceLink.ini");
// Check values
+ EXPECT_TRUE(profile::Profile::instance()->logs_enabled());
EXPECT_TRUE(profile::Profile::instance()->launch_hmi());
EXPECT_TRUE(profile::Profile::instance()->enable_policy());
EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled());
@@ -200,6 +202,7 @@ TEST_F(ProfileTest, UpdateBoolValues) {
// Update config file again
profile::Profile::instance()->UpdateValues();
// Values are same
+ EXPECT_TRUE(profile::Profile::instance()->logs_enabled());
EXPECT_TRUE(profile::Profile::instance()->launch_hmi());
EXPECT_TRUE(profile::Profile::instance()->enable_policy());
EXPECT_FALSE(profile::Profile::instance()->is_redecoding_enabled());
@@ -210,6 +213,7 @@ TEST_F(ProfileTest, UpdateBoolValues) {
Profile::instance()->config_file_name());
// Parameters after updating
+ EXPECT_FALSE(profile::Profile::instance()->logs_enabled());
EXPECT_FALSE(profile::Profile::instance()->launch_hmi());
EXPECT_FALSE(profile::Profile::instance()->enable_policy());
EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled());
@@ -218,6 +222,7 @@ TEST_F(ProfileTest, UpdateBoolValues) {
profile::Profile::instance()->UpdateValues();
// Parameters are same
+ EXPECT_FALSE(profile::Profile::instance()->logs_enabled());
EXPECT_FALSE(profile::Profile::instance()->launch_hmi());
EXPECT_FALSE(profile::Profile::instance()->enable_policy());
EXPECT_TRUE(profile::Profile::instance()->is_redecoding_enabled());
diff --git a/src/components/config_profile/test/smartDeviceLink.ini b/src/components/config_profile/test/smartDeviceLink.ini
index 41dabaa530..a2a553bc7e 100644
--- a/src/components/config_profile/test/smartDeviceLink.ini
+++ b/src/components/config_profile/test/smartDeviceLink.ini
@@ -21,6 +21,7 @@ VideoStreamingPort = 5050
AudioStreamingPort = 5080
[MAIN]
+LogsEnabled = true
; Contains .json/.ini files
AppConfigFolder =
; Contains output files, e.g. .wav
diff --git a/src/components/config_profile/test/smartDeviceLink_test.ini b/src/components/config_profile/test/smartDeviceLink_test.ini
index 6e2943b569..87ef526626 100644
--- a/src/components/config_profile/test/smartDeviceLink_test.ini
+++ b/src/components/config_profile/test/smartDeviceLink_test.ini
@@ -23,6 +23,7 @@ VideoStreamingPort = 5050
AudioStreamingPort = 5080
[MAIN]
+LogsEnabled = false
; Contains .json/.ini files
AppConfigFolder =
; Contains output files, e.g. .wav
diff --git a/src/components/include/utils/logger.h b/src/components/include/utils/logger.h
index 50d194245c..6f7415af78 100644
--- a/src/components/include/utils/logger.h
+++ b/src/components/include/utils/logger.h
@@ -41,6 +41,7 @@
#include <sstream>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/spi/loggingevent.h>
+ #include <log4cxx/logmanager.h>
#include "utils/push_log.h"
#include "utils/logger_status.h"
#include "utils/auto_trace.h"
@@ -64,6 +65,8 @@
void deinit_logger ();
#define DEINIT_LOGGER() deinit_logger()
+ #define DISABLE_LOGGER() ::log4cxx::LogManager::getLoggerRepository()->setThreshold(::log4cxx::Level::getOff())
+
#define LOG4CXX_IS_TRACE_ENABLED(logger) logger->isTraceEnabled()
log4cxx_time_t time_now();