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<SinkType>
167 createSink(boost::shared_ptr<std::ostream> stream_ptr,
168 std::string comm_filter);
231 logging::formatting_ostream &strm);
250namespace LogKeywords {
258 boost::log::attributes::named_scope::value_type)
260 boost::log::attributes::timer::value_type)
284#define MOFEM_LOG_CHANNEL(channel) \
285 { MoFEM::LogManager::setLog(channel); }
296#define MOFEM_LOG_ATTRIBUTES(channel, bit) \
297 { MoFEM::LogManager::addAttributes(channel, bit); }
308#define MOFEM_LOG(channel, severity) \
309 BOOST_LOG_SEV(MoFEM::LogManager::getLog(channel), severity)
311#define MOFEM_LOG_C(channel, severity, format, ...) \
312 MOFEM_LOG(channel, severity) \
313 << MoFEM::LogManager::getCLikeFormatedString(format, __VA_ARGS__)
325#define MOFEM_LOG_FUNCTION() \
326 BOOST_LOG_NAMED_SCOPE_INTERNAL( \
327 BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_named_scope_sentry_), \
328 PETSC_FUNCTION_NAME, __FILE__, __LINE__, \
329 ::boost::log::attributes::named_scope_entry::function)
339#define MOFEM_LOG_TAG(channel, tag) MoFEM::LogManager::addTag(channel, tag);
345#define MOFEM_LOG_SYNCHRONISE(comm) \
346 PetscSynchronizedFlush(comm, MoFEM::LogManager::dummy_mofem_fd);
352#define MOFEM_LOG_SEVERITY_SYNC(comm, severity) \
353 MOFEM_LOG("NULL", severity) << ([&] { \
354 MOFEM_LOG_SYNCHRONISE(comm); \
362#define MOFEM_TAG_AND_LOG(channel, severity, tag) \
363 MOFEM_LOG_TAG(channel, tag) \
364 MOFEM_LOG(channel, severity)
370#define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format, ...) \
371 MOFEM_LOG_TAG(channel, tag) \
372 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.
static constexpr std::array< char *const, error+1 > severityStrings
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static MoFEMErrorCode getOptions()
Get logger option.
sinks::synchronous_sink< sinks::text_ostream_backend > SinkType
static std::string getCLikeFormatedString(const char *fmt,...)
Converts formatted output to string.
virtual ~LogManager()=default
static void createDefaultSinks(MPI_Comm comm)
Create default sinks.
boost::log::sources::severity_channel_logger< SeverityLevel, std::string > LoggerType
Definition of the channel logger.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
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
base class for all interface classes