Removed Boost.Log dependency.

This commit is contained in:
Kirill Kirilenko 2016-10-02 02:37:35 +03:00
parent 7eb4b0f60e
commit bb59c65848
6 changed files with 39 additions and 15 deletions

View file

@ -0,0 +1,12 @@
#ifndef TELEBOTXX_LOGGING_HPP
#define TELEBOTXX_LOGGING_HPP
namespace telebotxx
{
extern bool debugMode;
/// \brief Enable/disable debug output
void setDebugMode(bool enabled);
}
#endif // TELEBOTXX_LOGGING_HPP

View file

@ -1,6 +1,8 @@
#include <telebotxx/BotApi.hpp>
#include <telebotxx/Exception.hpp>
#include <telebotxx/Logging.hpp>
#include <iostream>
#include <sstream>
#include <rapidjson/document.h>
@ -8,8 +10,6 @@
#include <cpr/cpr.h>
#include <boost/log/trivial.hpp>
namespace telebotxx
{
const rapidjson::Value& parseResponse(const rapidjson::Document& doc)
@ -91,7 +91,8 @@ public:
auto r = cpr::Get(cpr::Url{telegramMainUrl_ + "/getMe"});
auto& response = r.text;
BOOST_LOG_TRIVIAL(debug) << response;
if (debugMode)
std::cout << "Response: " << response << std::endl;
using namespace rapidjson;
Document doc;
@ -122,7 +123,8 @@ public:
);
auto& response = r.text;
BOOST_LOG_TRIVIAL(debug) << response;
if (debugMode)
std::cout << "Response: " << response << std::endl;
using namespace rapidjson;
Document doc;
@ -142,7 +144,8 @@ public:
);
auto& response = r.text;
BOOST_LOG_TRIVIAL(debug) << response;
if (debugMode)
std::cout << "Response: " << response << std::endl;
using namespace rapidjson;
Document doc;

View file

@ -2,12 +2,6 @@ cmake_minimum_required(VERSION 2.8)
message(STATUS "Configuring telebotxx")
find_package(Boost 1.54 REQUIRED log system)
include_directories(${Boost_INCLUDE_DIRS})
#find_package(CURLpp REQUIRED)
#include_directories(${CURLPP_INCLUDE_DIRS})
# Add required gcc flags
# For Windows we suppress all warnings because of Boost garbage :(
if(NOT WIN32)
@ -19,11 +13,12 @@ endif(NOT WIN32)
# Put compiled library to 'lib' directory
set(LIBRARY_OUTPUT_PATH "../lib")
set(SOURCE_FILES BotApi.cpp
Logging.cpp
User.cpp
)
add_library(telebotxx SHARED ${SOURCE_FILES})
target_link_libraries(telebotxx ${Boost_LIBRARIES} ${CPR_LIBRARIES})
set_property(TARGET telebotxx APPEND PROPERTY COMPILE_DEFINITIONS BOOST_LOG_DYN_LINK)
target_link_libraries(telebotxx ${CPR_LIBRARIES})
message(STATUS "Configuring telebotxx - done")

11
src/Logging.cpp Normal file
View file

@ -0,0 +1,11 @@
#include <telebotxx/Logging.hpp>
namespace telebotxx
{
bool debugMode = false;
void setDebugMode(bool enabled)
{
debugMode = enabled;
}
}

View file

@ -25,4 +25,4 @@ target_link_libraries(telebotxx-test telebotxx stdc++ ${Boost_LIBRARIES})
add_custom_target(test COMMAND telebotxx-test WORKING_DIRECTORY ".." DEPENDS telebotxx-test)
message(STATUS "Configuring telebotxx-test done")
message(STATUS "Configuring telebotxx-test - done")

View file

@ -1,6 +1,7 @@
#include "TestGlobal.hpp"
#include <telebotxx/BotApi.hpp>
#include <telebotxx/Logging.hpp>
#include <memory>
#include <fstream>
@ -61,6 +62,8 @@ struct TestConfig
throw std::invalid_argument("Config error: 'photo' must be unsigned int value.");
else
throw std::invalid_argument("Config error: 'photo' not set.");
telebotxx::setDebugMode(true);
}
~TestConfig()