v0.10.0
Macros | Enumerations | Functions
Mofem_log_manager

Log manager. More...

Collaboration diagram for Mofem_log_manager:

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 scope. More...
 
#define MOFEM_LOG_TAG(channel, tag)   MoFEM::LogManager::addTag(channel, tag);
 Tag channel. 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)

◆ 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);
#define MOFEM_LOG_ATTRIBUTES(channel, bit)
Add attributes to channel.
Definition: LogManager.hpp:300
Examples
add_cubit_meshsets.cpp, continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, log.cpp, and matrix_function.cpp.

Definition at line 300 of file LogManager.hpp.

◆ MOFEM_LOG_CHANNEL

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

Set and reset channel.

#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:288

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

Examples
add_cubit_meshsets.cpp, build_large_problem.cpp, log.cpp, and test_cache_on_entities.cpp.

Definition at line 288 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 scope.

Macro 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
continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, and log.cpp.

Definition at line 329 of file LogManager.hpp.

◆ MOFEM_LOG_TAG

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

Tag channel.

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

Examples
add_cubit_meshsets.cpp, contact.cpp, dynamic_elastic.cpp, eigen_elastic.cpp, elasticity.cpp, ep.cpp, heat_method.cpp, log.cpp, nonlinear_dynamics.cpp, plastic.cpp, and test_cache_on_entities.cpp.

Definition at line 343 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 ( const std::string  channel,
const int  bit = 0 
)
static

Add attributes to channel.

Parameters
channel
bit

Definition at line 356 of file LogManager.cpp.

356  {
357  addAttributes(getLog(channel), bit);
358 }
static void addAttributes(LogManager::LoggerType &lg, const int bit=0)
Add attributes to logger.
Definition: LogManager.cpp:338
static LoggerType & getLog(const std::string channel)
Get logger by channel.
Definition: LogManager.cpp:374

◆ addAttributes() [2/2]

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

Add attributes to logger.

Parameters
lg
bit

Definition at line 338 of file LogManager.cpp.

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

◆ addTag() [1/2]

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

Add tag to channel.

Parameters
channel
tag

Definition at line 364 of file LogManager.cpp.

364  {
365  getLog(channel).add_attribute("Tag", attrs::constant<std::string>(tag));
366 }

◆ addTag() [2/2]

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

Add tag to logger.

Parameters
lg
tag

Definition at line 360 of file LogManager.cpp.

360  {
361  lg.add_attribute("Tag", attrs::constant<std::string>(tag));
362 }

◆ getLog()

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

Get logger by channel.

Parameters
channel
Returns
LoggerType&

Definition at line 374 of file LogManager.cpp.

374  {
375  return InternalData::logChannels.at(channel);
376 }
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
add_cubit_meshsets.cpp, contact.cpp, continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, continuity_check_on_skeleton_with_simple_2d_for_hcurl.cpp, dynamic_elastic.cpp, eigen_elastic.cpp, elasticity.cpp, ep.cpp, heat_method.cpp, log.cpp, matrix_function.cpp, nonlinear_dynamics.cpp, and plastic.cpp.

Definition at line 368 of file LogManager.cpp.

368  {
369  InternalData::logChannels[channel] =
370  LoggerType(boost::log::keywords::channel = channel);
371  return InternalData::logChannels[channel];
372 }
boost::log::sources::severity_channel_logger< SeverityLevel, std::string > LoggerType
Definition of the channel logger.
Definition: LogManager.hpp:77