Skip to content

Commit

Permalink
Merge pull request #927 from Tradias/no-log-unneeded-includes
Browse files Browse the repository at this point in the history
Do not include Boost.Log related headers when MQTT_USE_LOG is off
  • Loading branch information
redboltz authored Apr 9, 2022
2 parents fa56ace + 866d850 commit 14cf0cd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions example/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <thread>
#include <fstream>
#include <iostream>

#include <boost/program_options.hpp>
#include <boost/format.hpp>
Expand Down
2 changes: 2 additions & 0 deletions example/broker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <boost/format.hpp>

#include <fstream>
#include <iostream>
#include <iomanip>
#include <algorithm>

namespace as = boost::asio;
Expand Down
2 changes: 2 additions & 0 deletions example/client_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// http://www.boost.org/LICENSE_1_0.txt)

#include <iostream>
#include <iomanip>
#include <fstream>

#include <boost/program_options.hpp>
#include <boost/format.hpp>
Expand Down
2 changes: 2 additions & 0 deletions include/mqtt/broker/retained_topic_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#if !defined(MQTT_BROKER_RETAINED_TOPIC_MAP_HPP)
#define MQTT_BROKER_RETAINED_TOPIC_MAP_HPP

#include <deque>

#include <boost/functional/hash.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
Expand Down
12 changes: 8 additions & 4 deletions include/mqtt/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#if !defined(MQTT_LOG_HPP)
#define MQTT_LOG_HPP

#include <tuple>
#include <cstddef>
#include <ostream>
#include <string>

#if defined(MQTT_USE_LOG)

#include <boost/log/core.hpp>
#include <boost/log/attributes.hpp>
Expand All @@ -24,12 +28,12 @@
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/comparison/greater_equal.hpp>

#endif // defined(MQTT_USE_LOG)

#include <mqtt/namespace.hpp>

namespace MQTT_NS {

namespace log = boost::log;

struct channel : std::string {
using std::string::string;
};
Expand Down Expand Up @@ -72,7 +76,7 @@ inline constexpr null_log const& operator<<(null_log const& o, T const&) { retur

// template arguments are defined in MQTT_NS
// filter and formatter can distinguish mqtt_cpp's channel and severity by their types
using global_logger_t = log::sources::severity_channel_logger<severity_level, channel>;
using global_logger_t = boost::log::sources::severity_channel_logger<severity_level, channel>;
inline global_logger_t& logger() {
thread_local global_logger_t l;
return l;
Expand Down
5 changes: 5 additions & 0 deletions include/mqtt/setup_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@

#include <mqtt/namespace.hpp>
#include <mqtt/log.hpp>

#if defined(MQTT_USE_LOG)

#include <mqtt/move.hpp>

#include <boost/filesystem.hpp>
#include <boost/date_time/posix_time/posix_time_io.hpp>

#endif // defined(MQTT_USE_LOG)

namespace MQTT_NS {

#if defined(MQTT_USE_LOG)
Expand Down

0 comments on commit 14cf0cd

Please sign in to comment.