Skip to content

Commit

Permalink
Boost log -> spdlog
Browse files Browse the repository at this point in the history
  • Loading branch information
msgmaxim committed Jun 25, 2019
1 parent 425b864 commit 3bf4bbf
Show file tree
Hide file tree
Showing 13 changed files with 307 additions and 319 deletions.
37 changes: 31 additions & 6 deletions common/src/common.h
Expand Up @@ -9,18 +9,23 @@
#include <boost/log/attributes/mutable_constant.hpp>
#include <boost/log/trivial.hpp>

#include "spdlog/spdlog.h"

namespace logging = boost::log;
namespace fs = boost::filesystem;

// clang-format off
#define LOKI_LOG(lvl)\
BOOST_LOG_STREAM_WITH_PARAMS(logging::trivial::logger::get(),\
(set_get_attrib("File", fs::path(__FILE__).filename().string())) \
(set_get_attrib("Line", __LINE__)) \
(set_get_attrib("Func", std::string(__FUNCTION__))) \
(logging::keywords::severity = logging::trivial::lvl))
// #define LOKI_LOG(lvl)\
// BOOST_LOG_STREAM_WITH_PARAMS(logging::trivial::logger::get(),\
// (set_get_attrib("File", fs::path(__FILE__).filename().string())) \
// (set_get_attrib("Line", __LINE__)) \
// (set_get_attrib("Func", std::string(__FUNCTION__))) \
// (logging::keywords::severity = logging::trivial::lvl))
// clang-format on

#define LOKI_LOG(LVL, ...)\
spdlog::get("multi_sink")->LVL(__VA_ARGS__)

// Set attribute and return the new value
template <typename ValueType>
ValueType set_get_attrib(const char* name, ValueType value) {
Expand Down Expand Up @@ -69,6 +74,26 @@ struct sn_record_t {
const std::string& ip() const { return ip_; }
};

namespace fmt {

template<>
struct formatter<sn_record_t> {

template<typename ParseContext>
constexpr auto parse(ParseContext &ctx) { return ctx.begin(); }

template<typename FormatContext>
auto format(const sn_record_t &d, FormatContext &ctx) {
#ifdef INTEGRATION_TEST
return format_to(ctx.out(), "{}", d.port());
#else
return format_to(ctx.out(), "{}", d.sn_address());
#endif
}
};

}

namespace loki {

/// message as received by client
Expand Down
2 changes: 1 addition & 1 deletion crypto/CMakeLists.txt
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)

project(crypto)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CXX_STANDARD_REQUIRED ON)

set(SOURCES
Expand Down

0 comments on commit 3bf4bbf

Please sign in to comment.