Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not include Boost.Log related headers when MQTT_USE_LOG is off #927

Merged
merged 5 commits into from
Apr 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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