v0.9.2
Classes | Macros | Enumerations | Functions
Mofem_log_manager

Log manager. More...

Collaboration diagram for Mofem_log_manager:

Classes

struct  MoFEM::LogManager
 Log manager is used to build and partition problems. More...
 

Macros

#define MOFEM_LOG_CHANNEL(channel)   { MoFEM::LogManager::setLog(channel); }
 Set and reset channel. More...
 
#define MOFEM_LOG_ATTRIBUTES(channel, bit)   { MoFEM::LogManager::addAttributes(channel, bit); }
 Add attributes to channel. More...
 
#define MOFEM_LOG(channel, severity)   BOOST_LOG_SEV(MoFEM::LogManager::getLog(channel), severity)
 Log. More...
 
#define MOFEM_LOG_FUNCTION()
 Set scopeMacro for function scope markup. The scope name is constructed with help of compiler and contains the current function signature. The scope name is pushed to the end of the current thread scope list. More...
 
#define MOFEM_LOG_TAG(channel, tag)   MoFEM::LogManager::addTag(channel, tag);
 Tag channelTag channel tag is set until MOFEM_LOG_CHANNEL is called, then new tag can be set. More...
 

Enumerations

enum  MoFEM::LogManager::SeverityLevel {
  MoFEM::LogManager::noisy, MoFEM::LogManager::verbose, MoFEM::LogManager::inform, MoFEM::LogManager::warning,
  MoFEM::LogManager::error
}
 Severity levels. More...
 
enum  MoFEM::LogManager::LogAttributesBits { MoFEM::LogManager::BitLineID = 1 << 0, MoFEM::LogManager::BitScope = 1 << 1 }
 Tag attributes switches. More...
 

Functions

static void MoFEM::LogManager::addAttributes (LogManager::LoggerType &lg, const int bit=0)
 Add attributes to logger. More...
 
static void MoFEM::LogManager::addAttributes (const std::string channel, const int bit=0)
 Add attributes to channel. More...
 
static LoggerTypeMoFEM::LogManager::setLog (const std::string channel)
 Set ans resset chanel logger. More...
 
static LoggerTypeMoFEM::LogManager::getLog (const std::string channel)
 Get logger by channel. More...
 
static void MoFEM::LogManager::addTag (LogManager::LoggerType &lg, const std::string tag)
 Add tag to logger. More...
 
static void MoFEM::LogManager::addTag (const std::string channel, const std::string tag)
 Add tag to channel. More...
 

Detailed Description

Log manager.

Logging manager based on Boost.Log (Boost.Log v2)

Macro Definition Documentation

◆ MOFEM_LOG

#define MOFEM_LOG (   channel,
  severity 
)    BOOST_LOG_SEV(MoFEM::LogManager::getLog(channel), severity)

Log.

MOFEM_LOG("WORLD", LogManager::SeverityLevel::inform) << "Hello world";
Examples
add_cubit_meshsets.cpp, elasticity.cpp, and log.cpp.

Definition at line 303 of file LogManager.hpp.

◆ MOFEM_LOG_ATTRIBUTES

#define MOFEM_LOG_ATTRIBUTES (   channel,
  bit 
)    { MoFEM::LogManager::addAttributes(channel, bit); }

Add attributes to channel.

MOFEM_LOG_ATTRIBUTES("SYNC", LogManager::BitLineID | LogManager::BitScope);
Examples
add_cubit_meshsets.cpp, and log.cpp.

Definition at line 291 of file LogManager.hpp.

◆ MOFEM_LOG_CHANNEL

#define MOFEM_LOG_CHANNEL (   channel)    { MoFEM::LogManager::setLog(channel); }

Set and reset channel.

Are three default type of channels, SELF, ech processor prints to the standard output, WORLD, only processor one prints, and SYNC all processors prints synchronously.

Examples
add_cubit_meshsets.cpp, elasticity.cpp, and log.cpp.

Definition at line 279 of file LogManager.hpp.

◆ MOFEM_LOG_FUNCTION

#define MOFEM_LOG_FUNCTION ( )
Value:
BOOST_LOG_NAMED_SCOPE_INTERNAL( \
BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_named_scope_sentry_), \
PETSC_FUNCTION_NAME, __FILE__, __LINE__, \
::boost::log::attributes::named_scope_entry::function)

Set scopeMacro for function scope markup. The scope name is constructed with help of compiler and contains the current function signature. The scope name is pushed to the end of the current thread scope list.

Not all compilers have support for this macro. The exact form of the scope name may vary from one compiler to another.

Examples
log.cpp.

Definition at line 320 of file LogManager.hpp.

◆ MOFEM_LOG_TAG

#define MOFEM_LOG_TAG (   channel,
  tag 
)    MoFEM::LogManager::addTag(channel, tag);

Tag channelTag channel tag is set until MOFEM_LOG_CHANNEL is called, then new tag can be set.

Examples
elasticity.cpp, and log.cpp.

Definition at line 334 of file LogManager.hpp.

Enumeration Type Documentation

◆ LogAttributesBits

Tag attributes switches.

Enumerator
BitLineID 
BitScope 

Definition at line 60 of file LogManager.hpp.

60  {
61  BitLineID = 1 << 0,
62  BitScope = 1 << 1,
63  };

◆ SeverityLevel

Severity levels.

Enumerator
noisy 
verbose 
inform 
warning 
error 

Definition at line 46 of file LogManager.hpp.

Function Documentation

◆ addAttributes() [1/2]

void MoFEM::LogManager::addAttributes ( LogManager::LoggerType lg,
const int  bit = 0 
)
static

Add attributes to logger.

Parameters
lg
bit

Definition at line 333 of file LogManager.cpp.

333  {
334 
335  if (bit == 0)
336  return;
337 
338  if (bit & (BitLineID | BitScope)) {
339 
340  if (bit & BitLineID)
341  lg.add_attribute("LineID", attrs::counter<unsigned int>(1));
342 
343  if (bit & BitScope)
344  lg.add_attribute("Scope", attrs::named_scope());
345 
346  } else {
347  THROW_MESSAGE("Wrong cast");
348  }
349 }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:626

◆ addAttributes() [2/2]

void MoFEM::LogManager::addAttributes ( const std::string  channel,
const int  bit = 0 
)
static

Add attributes to channel.

Parameters
channel
bit

Definition at line 351 of file LogManager.cpp.

351  {
352  addAttributes(getLog(channel), bit);
353 }
static void addAttributes(LogManager::LoggerType &lg, const int bit=0)
Add attributes to logger.
Definition: LogManager.cpp:333
static LoggerType & getLog(const std::string channel)
Get logger by channel.
Definition: LogManager.cpp:369

◆ addTag() [1/2]

void MoFEM::LogManager::addTag ( LogManager::LoggerType lg,
const std::string  tag 
)
static

Add tag to logger.

Parameters
lg
tag

Definition at line 355 of file LogManager.cpp.

355  {
356  lg.add_attribute("Tag", attrs::constant<std::string>(tag));
357 }

◆ addTag() [2/2]

void MoFEM::LogManager::addTag ( const std::string  channel,
const std::string  tag 
)
static

Add tag to channel.

Parameters
channel
tag

Definition at line 359 of file LogManager.cpp.

359  {
360  getLog(channel).add_attribute("Tag", attrs::constant<std::string>(tag));
361 }
static LoggerType & getLog(const std::string channel)
Get logger by channel.
Definition: LogManager.cpp:369

◆ getLog()

LogManager::LoggerType & MoFEM::LogManager::getLog ( const std::string  channel)
static

Get logger by channel.

Parameters
channel
Returns
LoggerType&

Definition at line 369 of file LogManager.cpp.

369  {
370  return InternalData::logChannels.at(channel);
371 }
static std::map< std::string, LoggerType > logChannels
Definition: LogManager.cpp:93

◆ setLog()

LogManager::LoggerType & MoFEM::LogManager::setLog ( const std::string  channel)
static

Set ans resset chanel logger.

Parameters
channel
Returns
LoggerType&
Examples
elasticity.cpp.

Definition at line 363 of file LogManager.cpp.

363  {
364  InternalData::logChannels[channel] =
365  LoggerType(boost::log::keywords::channel = channel);
366  return InternalData::logChannels[channel];
367 }
static std::map< std::string, LoggerType > logChannels
Definition: LogManager.cpp:93
boost::log::sources::severity_channel_logger< SeverityLevel, std::string > LoggerType
Definition of the channel logger.
Definition: LogManager.hpp:77