CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
23 #include <boost/log/attributes/constant.hpp>
24 #include <boost/log/core.hpp>
25 #include <boost/log/detail/light_rw_mutex.hpp>
26 #include <boost/log/sources/global_logger_storage.hpp>
27 #include <boost/log/sources/threading_models.hpp>
28 #include <boost/log/trivial.hpp>
29 #include <boost/thread/lock_guard.hpp>
31 namespace catapult {
namespace utils {
38 Trace = boost::log::trivial::trace,
50 Error = boost::log::trivial::error,
53 Fatal = boost::log::trivial::fatal,
196 template<
typename TAttributes>
199 using IteratorType =
typename std::remove_reference_t<TAttributes>::iterator;
216 template<
typename TBase,
typename TTraits>
229 template<
typename TArgs>
236 boost::lock_guard<threading_model>,
237 typename TBase::open_record_lock,
238 typename TBase::add_attribute_lock,
239 typename TBase::remove_attribute_lock
243 template<
typename TArgs>
246 const auto& keyword = boost::parameter::keyword<typename TTraits::TagType>::instance;
247 const auto& value = args[keyword];
250 auto& attrs = TBase::attributes();
251 auto result = TBase::add_attribute_unlocked(
253 boost::log::attributes::constant<typename TTraits::Type>(value));
254 auto iter = result.second ? result.first : attrs.end();
257 EraseOnExit<decltype(attrs)> eraseGuard(attrs, iter);
260 return TBase::open_record_unlocked(args);
265 template<
typename TCustomFeatureTraits>
267 template<
typename TBase>
275 BOOST_PARAMETER_KEYWORD(tag, line)
276 BOOST_PARAMETER_KEYWORD(tag, file)
277 BOOST_PARAMETER_KEYWORD(tag, subcomponent)
284 static constexpr
auto Name =
"Line";
291 static constexpr
auto Name =
"File";
298 static constexpr
auto Name =
"Subcomponent";
303 public boost::log::sources::basic_composite_logger<
306 boost::log::sources::multi_thread_model<boost::log::aux::light_rw_mutex>,
307 boost::log::sources::features<
308 boost::log::sources::severity<boost::log::trivial::severity_level>,
309 custom_info_tagger<LineNumberTraits>,
310 custom_info_tagger<FilenameTraits>,
311 custom_info_tagger<SubcomponentTraits>>> {
323 #define CATAPULT_LOG_WITH_LOGGER_LEVEL_TAG(LOGGER, LEVEL, TAG) \
324 BOOST_LOG_STREAM_WITH_PARAMS( \
326 (::catapult::utils::log::keywords::file = (::catapult::utils::ExtractFilename(__FILE__))) \
327 (::catapult::utils::log::keywords::line = (static_cast<unsigned int>(__LINE__))) \
328 (::catapult::utils::log::keywords::subcomponent = (TAG)) \
329 (::boost::log::keywords::severity = (static_cast<boost::log::trivial::severity_level>(LEVEL))))
332 #define CATAPULT_LOG_WITH_LOGGER_LEVEL(LOGGER, LEVEL) \
333 CATAPULT_LOG_WITH_LOGGER_LEVEL_TAG(LOGGER, LEVEL, (::catapult::utils::ExtractDirectoryName(__FILE__)))
336 #define CATAPULT_LOG_LEVEL(LEVEL) \
337 CATAPULT_LOG_WITH_LOGGER_LEVEL(::catapult::utils::log::global_logger::get(), LEVEL)
340 #define CATAPULT_LOG(SEV) \
341 CATAPULT_LOG_WITH_LOGGER_LEVEL( \
342 ::catapult::utils::log::global_logger::get(), \
343 (static_cast<::catapult::utils::LogLevel>(boost::log::trivial::SEV)))
static constexpr auto ColorMode
Definition: Logging.cpp:90
Colors
Definition: Logging.cpp:65
def debug(*args)
Definition: Parser.py:46
const char * Type
Definition: Logging.h:289
void addConsoleLogger(const BasicLoggerOptions &options, const LogFilter &filter)
Adds a console logger with the specified options and filter.
Definition: Logging.cpp:253
custom_info_tagger_feature(const custom_info_tagger_feature &rhs)
Definition: Logging.h:226
Catapult logger type.
Definition: Logging.h:302
OverrideLevelsMap m_overrideLevels
Definition: Logging.cpp:181
Traits for attaching a line number to a log record.
Definition: Logging.h:281
BasicLoggerOptions()
Creates default options.
Definition: Logging.h:125
keywords::tag::file TagType
Definition: Logging.h:290
std::string FilePattern
Log filename pattern.
Definition: Logging.h:149
~LogFilter()
Destroys the log filter.
constexpr size_t CountOf(T const (&)[N]) noexcept
Returns the size of the specified array.
Definition: src/catapult/types.h:113
def warning(*args)
Definition: colorPrint.py:10
EraseOnExit(TAttributes &attrs, IteratorType &iter)
Definition: Logging.h:202
LogColorMode
Catapult (console) log color modes.
Definition: Logging.h:80
Definition: Logging.cpp:164
Filter used for filtering logs by level and/or component.
Definition: Logging.h:96
std::vector< SinkPointer > m_sinks
Definition: Logging.cpp:240
typename std::remove_reference_t< TAttributes >::iterator IteratorType
Definition: Logging.h:199
std::unique_ptr< Impl > m_pImpl
Definition: Logging.h:113
Level for logging fatal events.
void CatapultLogFlush()
Definition: Logging.cpp:283
void setLevel(const char *name, LogLevel level)
Sets the log level for the component specified by name.
Definition: Logging.cpp:198
uint64_t MinFreeSpace
Minimum size of free disk space in order to create log files.
Definition: Logging.h:158
constexpr std::underlying_type_t< TEnum > to_underlying_type(TEnum value)
Converts a strongly typed enumeration value to its underlying integral value.
Definition: Casting.h:37
~LoggingBootstrapper()
Destroys the bootstrapper.
std::string Directory
Log directory.
Definition: Logging.h:146
Basic logger options.
Definition: Logging.h:122
Definition: Logging.h:268
keywords::tag::subcomponent TagType
Definition: Logging.h:297
void addBackend(const boost::shared_ptr< TBackend > &pBackend, const BasicLoggerOptions &options, const LogFilter &filter)
Definition: Logging.cpp:218
Level for logging error events.
void setLevel(const char *name, LogLevel level)
Definition: Logging.cpp:175
static constexpr auto Name
Definition: Logging.h:298
TAttributes & m_attrs
Definition: Logging.h:211
Level for logging debug events.
Level for logging informational events.
Level for logging trace events.
static constexpr auto Name
Definition: Logging.h:284
FileLoggerOptions(const std::string &directory, const std::string &filePattern)
Creates options that specify the creation of log files with the pattern filePattern in the directory.
Definition: Logging.h:140
LogSinkType
Catapult log sink types.
Definition: Logging.h:67
void addSink(const TSinkPointer &pSink, LogColorMode colorMode, const LogFilter &filter)
Definition: Logging.cpp:232
LogLevel
Catapult log levels.
Definition: Logging.h:36
Traits for attaching a subcomponent tag to a log record.
Definition: Logging.h:295
typename TBase::threading_model threading_model
Definition: Logging.h:220
def info(*args)
Definition: forwardsValidation.py:12
void addFileLogger(const FileLoggerOptions &options, const LogFilter &filter)
Adds a file logger with the specified options and filter.
Definition: Logging.cpp:263
custom_info_tagger_feature()
Definition: Logging.h:223
File logger options.
Definition: Logging.h:138
LogColorMode ColorMode
Log color mode.
Definition: Logging.h:134
static constexpr auto Name
Definition: PtSynchronizer.cpp:31
Bootstraps boost logging.
Definition: Logging.h:166
LogFilter(LogLevel level)
Creates a log filter that sets the default log level across all components.
Definition: Logging.cpp:188
A const string buffer.
Definition: RawBuffer.h:68
std::ostream & operator<<(std::ostream &out, const BlockSpan &blockSpan)
Insertion operator for outputting blockSpan to out.
Definition: BlockSpan.cpp:27
boost::log::filter toBoostFilter() const
Creates an equivalent boost log filter.
Definition: Logging.cpp:194
Definition: Logging.cpp:206
RawString Type
Definition: Logging.h:296
A custom logging feature that allows tagging a log record with custom information.
Definition: Logging.h:217
Traits for attaching a filename to a log record.
Definition: Logging.h:288
typename TBase::char_type char_type
Definition: Logging.h:219
IteratorType & m_iter
Definition: Logging.h:212
custom_info_tagger_feature(const TArgs &args)
Definition: Logging.h:230
std::unique_ptr< Impl > m_pImpl
Definition: Logging.h:182
unsigned int Type
Definition: Logging.h:282
LogLevel m_defaultLevel
Definition: Logging.cpp:180
Definition: AddressExtractionExtension.cpp:28
static constexpr auto Name
Definition: Logging.h:291
typename boost::log::strictest_lock< boost::lock_guard< threading_model >, typename TBase::open_record_lock, typename TBase::add_attribute_lock, typename TBase::remove_attribute_lock >::type open_record_lock
Definition: Logging.h:240
LoggingBootstrapper()
Creates a bootstrapper.
Definition: Logging.cpp:247
LogSinkType SinkType
Log sink type.
Definition: Logging.h:131
~Impl()
Definition: Logging.cpp:208
keywords::tag::line TagType
Definition: Logging.h:283
void setLevel(LogLevel level)
Definition: Logging.cpp:171
Level for logging warning events.
~EraseOnExit()
Definition: Logging.h:205
Allows custom_info_tagger_feature to be used as a source feature.
Definition: Logging.h:266
Removes an item from an attributes collection on destruction.
Definition: Logging.h:197
boost::log::filter toBoostFilter() const
Definition: Logging.cpp:166
uint64_t RotationSize
File rotation size.
Definition: Logging.h:152
uint64_t MaxTotalSize
Maximum size of all log files.
Definition: Logging.h:155
boost::log::record open_record_unlocked(const TArgs &args)
Definition: Logging.h:244