11 #include <unordered_map> 13 #include <boost/thread.hpp> 14 #include <boost/function.hpp> 15 #include <boost/shared_ptr.hpp> 16 #include <boost/asio.hpp> 17 #include <boost/make_shared.hpp> 18 #include <boost/enable_shared_from_this.hpp> 19 #include <boost/chrono.hpp> 20 #include <boost/asio/waitable_timer_service.hpp> 22 #include <boost/asio.hpp> 23 #include <boost/bind.hpp> 29 #include "gtest/gtest.h" 32 #include "easylogging++.h" 33 #include "fileWatcher.h" 38 #define DPY_LOG_DEBUG_ON 39 #define DPY_LOG_INFO_ON 40 #define DPY_LOG_ERR_ON 41 #define DPY_LOG_WARN_ON 42 #define DPY_LOG_FATAL_ON 48 #ifdef DPY_LOG_DEBUG_ON 49 #define DPYLOG_DEBUG(formatString, ...)\ 50 do{ Logging::getLogger()->debug(formatString, ##__VA_ARGS__); }while (0) 52 #define DPYLOG_DEBUG(formatString, ...) 55 #ifdef DPY_LOG_INFO_ON 56 #define DPYLOG_INFO(formatString, ...)\ 57 do{ Logging::getLogger()->info(formatString, ##__VA_ARGS__); }while (0) 59 #define DPYLOG_INFO(formatString, ...) 62 #ifdef DPY_LOG_WARN_ON 63 #define DPYLOG_WARN(formatString, ...)\ 64 do{ Logging::getLogger()->warn(formatString, ##__VA_ARGS__); }while (0) 66 #define DPYLOG_WARN(formatString, ...) 70 #define DPYLOG_ERR(formatString, ...)\ 71 do{ Logging::getLogger()->error(formatString, ##__VA_ARGS__); }while (0) 73 #define DPYLOG_ERR(formatString, ...) 77 #ifdef DPY_LOG_FATAL_ON 78 #define DPYLOG_FATAL(formatString, ...)\ 79 do{ Logging::getLogger()->fatal(formatString, ##__VA_ARGS__); }while (0) 81 #define DPYLOG_FATAL(formatString, ...) 92 typedef boost::asio::basic_waitable_timer<boost::chrono::steady_clock>
steady_timer;
106 friend class LogConfiguration;
108 boost::asio::io_service mIo;
109 std::string m_appName;
110 std::string m_absPath;
111 std::time_t m_lastModificationTime;
113 std::vector<std::string> m_insertOrder;
114 std::unordered_map<std::string, Level> m_mapStringLevel;
115 std::unordered_map<std::string, el::ConfigurationType> m_mapStringProperty;
123 explicit Logging(std::string appName=
"default");
127 static el::Logger* getLogger();
133 void createLevelMap();
134 void createPropertyMap();
135 static bool openFile(boost::system::error_code& ec,
const std::string& fileName, std::stringstream& ss);
136 bool writeToJson(
const std::string& filename);
137 void checkModificationTime();
138 void easyLogConfig();
139 bool parseFromJson(boost::system::error_code& ec,
const std::string& fileName);
140 bool isValid(std::string appname);
141 bool checkHierarchy();
142 void fileWatcherHandler(std::string path_to_watch, FileStatus status);
147 FRIEND_TEST(Logging_test, isNameValidPASS);
148 FRIEND_TEST(Logging_test, isNameValidFAIL);
149 FRIEND_TEST(Logging_test, openFilePASS);
150 FRIEND_TEST(Logging_test, openFileFAIL);
151 FRIEND_TEST(Logging_test, writeToJsonPASS);
152 FRIEND_TEST(Logging_test, writeToJsonFAIL);
153 FRIEND_TEST(Logging_test, createPathPASS);
154 FRIEND_TEST(Logging_test, createPathFAIL);
155 FRIEND_TEST(Logging_test,checkCorrectHierarchy);
156 FRIEND_TEST(Logging_test,parseFromJsonCorrectly);
el::Level logLevel
Easylogging level.
Definition: logging.h:93
bool enabled
boolean to set if it is enabled or not
Definition: logging.h:94
It stores info about the logging level.
Definition: logging.h:92
boost::asio::basic_waitable_timer< boost::chrono::steady_clock > steady_timer
Typedef to use a steady timer.
Definition: logging.h:97
boost::asio::basic_waitable_timer< boost::chrono::steady_clock > steady_timer
Typedef to use a steady timer.
Definition: dpyMwClient.h:52
Implement the interaction with a inotify tool.
Definition: fileWatcher.h:17
This class is used by Services and Apps to log messages.
Definition: logging.h:106
Debug
An enum definition which represents the different modes of the Automatic Power configuration.
Definition: iPower.h:83