diff --git a/examples/pub/publisher.cpp b/examples/pub/publisher.cpp index 90a6068..f968a79 100644 --- a/examples/pub/publisher.cpp +++ b/examples/pub/publisher.cpp @@ -31,6 +31,9 @@ Publisher::Publisher() void Publisher::connect(const std::string &hostname, int portnumber, const std::string &username, const std::string &password, const std::string &lwt_topic, const std::string &lwt_message) { + m_mqtt_client.setLogLevel( osdev::components::log::LogLevel::Info ); + m_mqtt_client.setMask( osdev::components::log::LogMask::Upto ); + m_mqtt_client.connect( hostname, portnumber, osdev::components::mqtt::Credentials( username, password ), osdev::components::mqtt::mqtt_LWT( lwt_topic, lwt_message ) ); std::cout << "Client state : " << m_mqtt_client.state() << std::endl; } diff --git a/src/log.h b/include/log.h index 31e84a5..31e84a5 100644 --- a/src/log.h +++ b/include/log.h diff --git a/include/mqttclient.h b/include/mqttclient.h index 7eaa795..7e10d8d 100644 --- a/include/mqttclient.h +++ b/include/mqttclient.h @@ -31,12 +31,15 @@ #include // osdev::components::mqtt -#include "synchronizedqueue.h" -#include "istatecallback.h" -#include "serverstate.h" +#include "istatecallback.h" #include "imqttclient.h" #include "mqtt_lwt.h" +#include "serverstate.h" +#include "synchronizedqueue.h" + +// osdev::components::logger +#include "log.h" namespace osdev { namespace components { @@ -166,6 +169,22 @@ public: */ virtual std::string endpoint() const override; + /*! + * \brief setMask update the current logMask + * \param logMask - Enum defining the logmask used. + */ + void setMask ( osdev::components::log::LogMask logMask ); + /*! + * \brief setLogLevel update the current logLevel + * \param logLevel - Enum defining the logLevel used, in combination with Mask. + */ + void setLogLevel( osdev::components::log::LogLevel logLevel ); + /*! + * \brief setContext update the current context + * \param context - String containing the new context name. + */ + void setContext ( std::string context ); + private: /*! * \brief Callback used to pick up the connection status of the wrappers. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dedee11..51a66ae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,6 @@ include(compiler) include_directories( ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/submodules/logger/src ) set(SRC_LIST diff --git a/src/log.cpp b/src/log.cpp index 7feed80..95d8dfc 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -53,8 +53,8 @@ int toInt( LogLevel level ) std::string Log::s_context = std::string(); std::string Log::s_fileName = std::string(); -LogLevel Log::s_logLevel = LogLevel::Debug; -LogMask Log::s_logMask = LogMask::None; +LogLevel Log::s_logLevel = LogLevel::Info; +LogMask Log::s_logMask = LogMask::Upto; void Log::init( const std::string& context, const std::string& logFile, LogLevel logDepth ) { diff --git a/src/mqttclient.cpp b/src/mqttclient.cpp index e1454f4..48ea2a4 100644 --- a/src/mqttclient.cpp +++ b/src/mqttclient.cpp @@ -21,9 +21,6 @@ * ***************************************************************************/ #include "mqttclient.h" -// osdev::components::logger -#include "log.h" - // osdev::components::mqtt #include "clientpaho.h" #include "mqttutil.h" @@ -613,3 +610,18 @@ void MqttClient::eventHandler() } LogInfo("[MqttClient::eventHandler]", std::string( m_clientId + " - leaving event handler." ) ); } + +void MqttClient::setMask(log::LogMask logMask ) +{ + Log::setMask( logMask ); +} + +void MqttClient::setLogLevel(log::LogLevel logLevel) +{ + Log::setLogLevel( logLevel ); +} + +void MqttClient::setContext(std::string context) +{ + Log::setContext( context ); +}