BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
42 void set_name(
const std::string& n );
43 const std::string&
name()
const;
54 std::shared_ptr<impl> my;
59 #ifndef DEFAULT_LOGGER
60 #define DEFAULT_LOGGER
65 #define FC_MULTILINE_MACRO_BEGIN do {
67 # define FC_MULTILINE_MACRO_END \
68 __pragma(warning(push)) \
69 __pragma(warning(disable:4127)) \
71 __pragma(warning(pop))
73 # define FC_MULTILINE_MACRO_END } while (0)
76 #define fc_dlog( LOGGER, FORMAT, ... ) \
77 FC_MULTILINE_MACRO_BEGIN \
78 if( (LOGGER).is_enabled( fc::log_level::debug ) ) \
79 (LOGGER).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
80 FC_MULTILINE_MACRO_END
82 #define fc_ilog( LOGGER, FORMAT, ... ) \
83 FC_MULTILINE_MACRO_BEGIN \
84 if( (LOGGER).is_enabled( fc::log_level::info ) ) \
85 (LOGGER).log( FC_LOG_MESSAGE( info, FORMAT, __VA_ARGS__ ) ); \
86 FC_MULTILINE_MACRO_END
88 #define fc_wlog( LOGGER, FORMAT, ... ) \
89 FC_MULTILINE_MACRO_BEGIN \
90 if( (LOGGER).is_enabled( fc::log_level::warn ) ) \
91 (LOGGER).log( FC_LOG_MESSAGE( warn, FORMAT, __VA_ARGS__ ) ); \
92 FC_MULTILINE_MACRO_END
94 #define fc_elog( LOGGER, FORMAT, ... ) \
95 FC_MULTILINE_MACRO_BEGIN \
96 if( (LOGGER).is_enabled( fc::log_level::error ) ) \
97 (LOGGER).log( FC_LOG_MESSAGE( error, FORMAT, __VA_ARGS__ ) ); \
98 FC_MULTILINE_MACRO_END
100 #define dlog( FORMAT, ... ) \
101 FC_MULTILINE_MACRO_BEGIN \
102 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::debug ) ) \
103 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
104 FC_MULTILINE_MACRO_END
110 #define ulog( FORMAT, ... ) \
111 FC_MULTILINE_MACRO_BEGIN \
112 if( (fc::logger::get("user")).is_enabled( fc::log_level::debug ) ) \
113 (fc::logger::get("user")).log( FC_LOG_MESSAGE( debug, FORMAT, __VA_ARGS__ ) ); \
114 FC_MULTILINE_MACRO_END
117 #define ilog( FORMAT, ... ) \
118 FC_MULTILINE_MACRO_BEGIN \
119 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::info ) ) \
120 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( info, FORMAT, __VA_ARGS__ ) ); \
121 FC_MULTILINE_MACRO_END
123 #define wlog( FORMAT, ... ) \
124 FC_MULTILINE_MACRO_BEGIN \
125 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::warn ) ) \
126 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( warn, FORMAT, __VA_ARGS__ ) ); \
127 FC_MULTILINE_MACRO_END
129 #define elog( FORMAT, ... ) \
130 FC_MULTILINE_MACRO_BEGIN \
131 if( (fc::logger::get(DEFAULT_LOGGER)).is_enabled( fc::log_level::error ) ) \
132 (fc::logger::get(DEFAULT_LOGGER)).log( FC_LOG_MESSAGE( error, FORMAT, __VA_ARGS__ ) ); \
133 FC_MULTILINE_MACRO_END
135 #include <boost/preprocessor/seq/for_each.hpp>
136 #include <boost/preprocessor/seq/enum.hpp>
137 #include <boost/preprocessor/seq/size.hpp>
138 #include <boost/preprocessor/seq/seq.hpp>
139 #include <boost/preprocessor/stringize.hpp>
140 #include <boost/preprocessor/punctuation/paren.hpp>
143 #define FC_FORMAT_ARG(r, unused, base) \
144 BOOST_PP_STRINGIZE(base) ": ${" BOOST_PP_STRINGIZE( base ) "} "
146 #define FC_FORMAT_ARGS(r, unused, base) \
147 BOOST_PP_LPAREN() BOOST_PP_STRINGIZE(base),fc::variant(base,FC_MAX_LOG_OBJECT_DEPTH) BOOST_PP_RPAREN()
149 #define FC_FORMAT( SEQ )\
150 BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARG, v, SEQ )
154 #define FC_FORMAT_ARG_PARAMS( ... )\
155 BOOST_PP_SEQ_FOR_EACH( FC_FORMAT_ARGS, v, __VA_ARGS__ )
157 #define FC_DUMP_FORMAT_ARG_NAME(r, unused, base) \
158 "(" BOOST_PP_STRINGIZE(base) ")"
160 #define FC_DUMP_FORMAT_ARG_NAMES( SEQ )\
161 BOOST_PP_SEQ_FOR_EACH( FC_DUMP_FORMAT_ARG_NAME, v, SEQ )
166 #define idump( SEQ ) \
169 ilog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
171 ilog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
174 #define wdump( SEQ ) \
177 wlog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
179 wlog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
182 #define edump( SEQ ) \
185 elog( FC_FORMAT(SEQ), FC_FORMAT_ARG_PARAMS(SEQ) ); \
187 elog ( "[ERROR: Got exception while trying to dump ( ${args} )]",("args",FC_DUMP_FORMAT_ARG_NAMES(SEQ)) ); \
194 #ifdef FC_DISABLE_LOGGING
196 # define ulog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
198 # define elog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
200 # define wlog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
202 # define ilog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
204 # define dlog(...) FC_MULTILINE_MACRO_BEGIN FC_MULTILINE_MACRO_END
logger & operator=(const logger &)
logger & set_log_level(log_level e)
const std::string & name() const
log_level get_log_level() const
logger & set_parent(const logger &l)
bool is_enabled(log_level e) const
void set_name(const std::string &n)
std::vector< appender::ptr > get_appenders() const
aggregates a message along with the context and associated meta-information.
void add_appender(const appender::ptr &a)
std::shared_ptr< appender > ptr
void remove_appender(const appender::ptr &a)
static logger get(const std::string &name="default")
friend bool operator!=(const logger &, std::nullptr_t)
friend bool operator==(const logger &, std::nullptr_t)
Defines types and helper macros necessary for generating log messages.
logger get_parent() const