Add warning when serialized file is missing 41/201041/2
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 7 Mar 2019 11:12:55 +0000 (12:12 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 7 Mar 2019 14:22:41 +0000 (15:22 +0100)
Change-Id: I604b94cad042a5e65275705f7ca6a88b9fbaa9fb

src/internal/naive_policy_checker.cpp
src/internal/tslog.cpp
src/internal/tslog.hpp

index f925566..05721c3 100644 (file)
@@ -208,6 +208,8 @@ bool NaivePolicyChecker::initDb(const char *config_name, const char *serialized_
                        return true;
        }
 
+       tslog::logWarning(std::string(serialized_filename?:"<no_serialized_filename>").append(": serialized policy file not found, using XML policy file"));
+
        // fallback - we have only XML files
        return m_bus_db.initFromXML(config_name);
 }
index 6505c7d..b71e513 100644 (file)
@@ -24,9 +24,12 @@ bool tslog::verbose() { return g_verbosity > 0; }
 
 void tslog::logError(const char *error)
 {
-       if (tslog::enabled()) {
-               std::cout <<  error << std::endl;
-       }
-
+       log(error, "\n");
        LOGE("%s", error);
 }
+
+void tslog::logWarning(const std::string &warning)
+{
+       log(warning, "\n");
+       LOGW("%s", warning.c_str());
+}
index d6695a3..ec45407 100644 (file)
@@ -25,6 +25,7 @@
 #include <thread>
 #include <pthread.h>
 #include <stdlib.h>
+#include <string>
 
 typedef std::ostream& (*t_ManFun)(std::ostream&);
 
@@ -43,6 +44,7 @@ namespace tslog
        bool verbose();
 
        void logError(const char *error);
+       void logWarning(const std::string &warning);
 
        template <typename ...Args>
        void log_to_stream(std::ostream &stream, const Args &...args) {