7#define DEFAULT_LOGGER "default"
55 void add_appender(
const std::shared_ptr<appender>&
a );
59 std::shared_ptr<impl> my;
66#define FC_MULTILINE_MACRO_BEGIN do {
68# define FC_MULTILINE_MACRO_END \
69 __pragma(warning(push)) \
70 __pragma(warning(disable:4127)) \
72 __pragma(warning(pop))
74# define FC_MULTILINE_MACRO_END } while (0)
77#define fc_dlog( LOGGER, FORMAT, ... ) \
78 FC_MULTILINE_MACRO_BEGIN \
79 if( (LOGGER).is_enabled( fc::log_level::debug ) ) \
80 (LOGGER).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
81 FC_MULTILINE_MACRO_END
83#define fc_ilog( LOGGER, FORMAT, ... ) \
84 FC_MULTILINE_MACRO_BEGIN \
85 if( (LOGGER).is_enabled( fc::log_level::info ) ) \
86 (LOGGER).log( FC_LOG_MESSAGE( info, FORMAT, __VA_ARGS__ ) ); \
87 FC_MULTILINE_MACRO_END
89#define fc_wlog( LOGGER, FORMAT, ... ) \
90 FC_MULTILINE_MACRO_BEGIN \
91 if( (LOGGER).is_enabled( fc::log_level::warn ) ) \
92 (LOGGER).log( FC_LOG_MESSAGE( warn, FORMAT, __VA_ARGS__ ) ); \
93 FC_MULTILINE_MACRO_END
95#define fc_elog( LOGGER, FORMAT, ... ) \
96 FC_MULTILINE_MACRO_BEGIN \
97 if( (LOGGER).is_enabled( fc::log_level::error ) ) \
98 (LOGGER).log( FC_LOG_MESSAGE( error, FORMAT, __VA_ARGS__ ) ); \
99 FC_MULTILINE_MACRO_END
101#define dlog( FORMAT, ... ) \
102 FC_MULTILINE_MACRO_BEGIN \
103 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::debug ) ) \
104 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
105 FC_MULTILINE_MACRO_END
111#define ulog( FORMAT, ... ) \
112 FC_MULTILINE_MACRO_BEGIN \
113 if( (fc::logger::get("user")).is_enabled( fc::log_level::debug ) ) \
114 (fc::logger::get("user")).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
115 FC_MULTILINE_MACRO_END
118#define ilog( FORMAT, ... ) \
119 FC_MULTILINE_MACRO_BEGIN \
120 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::info ) ) \
121 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( info, FORMAT, __VA_ARGS__ ) ); \
122 FC_MULTILINE_MACRO_END
124#define wlog( FORMAT, ... ) \
125 FC_MULTILINE_MACRO_BEGIN \
126 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::warn ) ) \
127 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( warn, FORMAT, __VA_ARGS__ ) ); \
128 FC_MULTILINE_MACRO_END
130#define elog( FORMAT, ... ) \
131 FC_MULTILINE_MACRO_BEGIN \
132 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::error ) ) \
133 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( error, FORMAT, __VA_ARGS__ ) ); \
134 FC_MULTILINE_MACRO_END
136#include <boost/preprocessor/seq/for_each.hpp>
137#include <boost/preprocessor/seq/enum.hpp>
138#include <boost/preprocessor/seq/size.hpp>
139#include <boost/preprocessor/seq/seq.hpp>
140#include <boost/preprocessor/stringize.hpp>
141#include <boost/preprocessor/punctuation/paren.hpp>
144#define FC_FORMAT_ARG(r, unused, base) \
145 BOOST_PP_STRINGIZE(base) ": ${" BOOST_PP_STRINGIZE( base ) "} "
147#define FC_FORMAT_ARGS(r, unused, base) \
148 BOOST_PP_LPAREN() BOOST_PP_STRINGIZE(base),fc::variant(base) BOOST_PP_RPAREN()
150#define FC_FORMAT( SEQ )\
151 BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARG, v, SEQ )
155#define FC_FORMAT_ARG_PARAMS( ... )\
156 BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARGS, v, __VA_ARGS__ )
158#define idump( SEQ ) \
159 ilog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
160#define wdump( SEQ ) \
161 wlog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
162#define edump( SEQ ) \
163 elog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) )
168#ifdef FC_DISABLE_LOGGING
170# define ulog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
172# define elog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
174# define wlog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
176# define ilog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
178# define dlog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
aggregates a message along with the context and associated meta-information.
static void update(const fc::string &name, logger &log)
friend bool operator!=(const logger &, nullptr_t)
logger get_parent() const
logger & operator=(const logger &)
logger & set_log_level(log_level e)
static logger get(const fc::string &name=DEFAULT_LOGGER)
logger & set_parent(const logger &l)
void set_name(const fc::string &n)
friend bool operator==(const logger &, nullptr_t)
log_level get_log_level() const
const fc::string & name() const
bool is_enabled(log_level e) const
Defines types and helper macros necessary for generating log messages.
decltype(nullptr) nullptr_t
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a