7#ifndef __LOGMANAGER_HPP__
8 #define __LOGMANAGER_HPP__
10namespace attrs = boost::log::attributes;
11namespace logging = boost::log;
12namespace keywords = boost::log::keywords;
13namespace logging = boost::log;
14namespace sinks = boost::log::sinks;
15namespace src = boost::log::sources;
16namespace attrs = boost::log::attributes;
17namespace expr = boost::log::expressions;
37 (
char *)
"noisy", (
char *)
"verbose", (
char *)
"inform", (
char *)
"warning",
62 typedef boost::log::sources::severity_channel_logger<
SeverityLevel,
66 typedef sinks::synchronous_sink<sinks::text_ostream_backend>
SinkType;
129 static void addTag(
const std::string channel,
const std::string tag);
136 static boost::shared_ptr<std::ostream>
getStrmSelf();
150 static boost::shared_ptr<std::ostream>
getStrmSync();
157 static boost::shared_ptr<std::ostream>
getStrmNull();
166 static boost::shared_ptr<std::ostream>
getStrmSync(MPI_Comm comm, FILE *fd);
175 static boost::shared_ptr<SinkType>
176 createSink(boost::shared_ptr<std::ostream> stream_ptr,
177 std::string comm_filter);
240 logging::formatting_ostream &strm);
258namespace LogKeywords {
266 boost::log::attributes::named_scope::value_type)
268 boost::log::attributes::timer::value_type)
292 #define MOFEM_LOG_CHANNEL(channel) \
293 { MoFEM::LogManager::setLog(channel); }
304 #define MOFEM_LOG_ATTRIBUTES(channel, bit) \
305 { MoFEM::LogManager::addAttributes(channel, bit); }
316 #define MOFEM_LOG(channel, severity) \
317 BOOST_LOG_SEV(MoFEM::LogManager::getLog(channel), severity)
319 #define MOFEM_LOG_C(channel, severity, format, ...) \
320 MOFEM_LOG(channel, severity) \
321 << MoFEM::LogManager::getCLikeFormatedString(format, __VA_ARGS__)
333 #define MOFEM_LOG_FUNCTION() \
334 BOOST_LOG_NAMED_SCOPE_INTERNAL( \
335 BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_named_scope_sentry_), \
336 PETSC_FUNCTION_NAME, __FILE__, __LINE__, \
337 ::boost::log::attributes::named_scope_entry::function)
347 #define MOFEM_LOG_TAG(channel, tag) MoFEM::LogManager::addTag(channel, tag);
353 #define MOFEM_LOG_SYNCHRONISE(comm) \
354 PetscSynchronizedFlush(comm, MoFEM::LogManager::dummy_mofem_fd);
360 #define MOFEM_LOG_SEVERITY_SYNC(comm, severity) \
361 MOFEM_LOG("NULL", severity) << ([&] { \
362 MOFEM_LOG_SYNCHRONISE(comm); \
370 #define MOFEM_LOG_FILE_SYNCHRONISE(comm, fd) PetscSynchronizedFlush(comm, fd);
376 #define MOFEM_TAG_AND_LOG(channel, severity, tag) \
377 MOFEM_LOG_TAG(channel, tag) \
378 MOFEM_LOG(channel, severity)
384 #define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format, ...) \
385 MOFEM_LOG_TAG(channel, tag) \
386 MOFEM_LOG_C(channel, severity, format, __VA_ARGS__)
PetscErrorCode PetscVFPrintfDefault(FILE *fd, const char *format, va_list Argp)
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
SeverityLevel
Severity levels.
LogAttributesBits
Tag attributes switches.
static void addTag(LogManager::LoggerType &lg, const std::string tag)
Add tag to logger.
static void addAttributes(LogManager::LoggerType &lg, const int bit=0)
Add attributes to logger.
static LoggerType & getLog(const std::string channel)
Get logger by channel.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
BOOST_LOG_ATTRIBUTE_KEYWORD(scope, "Scope", boost::log::attributes::named_scope::value_type) BOOST_LOG_ATTRIBUTE_KEYWORD(timeline
implementation of Data Operators for Forces and Sources
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
Log manager is used to build and partition problems.
static boost::shared_ptr< std::ostream > getStrmNull()
Get the strm null object.
boost::log::sources::severity_channel_logger< SeverityLevel, std::string > LoggerType
Definition of the channel logger.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
LogManager(const MoFEM::Core &core)
static MoFEMErrorCode getOptions()
Get logger option.
static std::string getCLikeFormatedString(const char *fmt,...)
Converts formatted output to string.
virtual ~LogManager()=default
static void createDefaultSinks(MPI_Comm comm)
Create default sinks.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
sinks::synchronous_sink< sinks::text_ostream_backend > SinkType
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
static PetscErrorCode logPetscFPrintf(FILE *fd, const char format[], va_list Argp)
Use to handle PETSc output.
static std::string getVLikeFormatedString(const char *fmt, va_list args)
Converts formatted output to string.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
static void recordFormatterDefault(logging::record_view const &rec, logging::formatting_ostream &strm)
Default record formatter.
static bool checkIfChannelExist(const std::string channel)
Check if channel exist.
static boost::shared_ptr< std::ostream > getStrmSelf()
Get the strm self object.
static std::string petscStringCache
static FILE * dummy_mofem_fd
Dummy file pointer (DO NOT USE)
static boost::shared_ptr< InternalData > internalDataPtr
static constexpr std::array< char *const, error+1 > severityStrings
base class for all interface classes