v0.14.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);
Examples
add_cubit_meshsets.cpp, continuity_check_on_skeleton_with_simple_2d_for_h1.cpp, log.cpp, and matrix_function.cpp.

Definition at line 296 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, each processor prints to the standard output, WORLD, only processor one prints, and SYNC all processors prints synchronously.

Examples
add_cubit_meshsets.cpp, adolc_plasticity.cpp, build_large_problem.cpp, free_surface.cpp, hcurl_divergence_operator_2d.cpp, HenckyOps.hpp, log.cpp, partition_mesh.cpp, phase.cpp, plastic.cpp, PlasticOps.hpp, poisson_2d_homogeneous.cpp, remove_entities_from_problem_not_partitioned.cpp, schur_test_diag_mat.cpp, seepage.cpp, test_cache_on_entities.cpp, thermo_elastic.cpp, and ThermoElasticOps.hpp.

Definition at line 284 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 325 of file LogManager.hpp.

◆ MOFEM_LOG_TAG

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

Enumeration Type Documentation

◆ LogAttributesBits

Tag attributes switches.

Enumerator
BitLineID 
BitScope 

Definition at line 47 of file LogManager.hpp.

47  {
48  BitLineID = 1 << 0,
49  BitScope = 1 << 1,
50  };

◆ SeverityLevel

Severity levels.

Enumerator
noisy 
verbose 
inform 
warning 
error 

Definition at line 33 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 377 of file LogManager.cpp.

377  {
378  addAttributes(getLog(channel), bit);
379 }

◆ 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 359 of file LogManager.cpp.

359  {
360 
361  if (bit == 0)
362  return;
363 
364  if (bit & (BitLineID | BitScope)) {
365 
366  if (bit & BitLineID)
367  lg.add_attribute("LineID", attrs::counter<unsigned int>(1));
368 
369  if (bit & BitScope)
370  lg.add_attribute("Scope", attrs::named_scope());
371 
372  } else {
373  THROW_MESSAGE("Wrong cast");
374  }
375 }

◆ 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 385 of file LogManager.cpp.

385  {
386  getLog(channel).add_attribute("Tag", attrs::constant<std::string>(tag));
387 }

◆ 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 381 of file LogManager.cpp.

381  {
382  lg.add_attribute("Tag", attrs::constant<std::string>(tag));
383 }

◆ getLog()

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

Get logger by channel.

Parameters
channel
Returns
LoggerType&

Definition at line 395 of file LogManager.cpp.

395  {
396  auto it = InternalData::logChannels.find(channel);
397  if (it == InternalData::logChannels.end()) {
399  "Channel <" + channel + "> not found");
400  }
401  return it->second;
402 }

◆ setLog()

LogManager::LoggerType & MoFEM::LogManager::setLog ( const std::string  channel)
static
MoFEM::LogManager::noisy
@ noisy
Definition: LogManager.hpp:33
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::LogManager::getLog
static LoggerType & getLog(const std::string channel)
Get logger by channel.
Definition: LogManager.cpp:395
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:609
MOFEM_LOG_ATTRIBUTES
#define MOFEM_LOG_ATTRIBUTES(channel, bit)
Add attributes to channel.
Definition: LogManager.hpp:296
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
MoFEM::LogManager::LoggerType
boost::log::sources::severity_channel_logger< SeverityLevel, std::string > LoggerType
Definition of the channel logger.
Definition: LogManager.hpp:64
MoFEM::LogManager::BitLineID
@ BitLineID
Definition: LogManager.hpp:48
MoFEM::LogManager::BitScope
@ BitScope
Definition: LogManager.hpp:49
MoFEM::LogManager::InternalData::logChannels
static std::map< std::string, LoggerType > logChannels
Definition: LogManager.cpp:109
MoFEM::LogManager::inform
@ inform
Definition: LogManager.hpp:33
bit
auto bit
set bit
Definition: hanging_node_approx.cpp:75
MoFEM::LogManager::error
@ error
Definition: LogManager.hpp:33
MoFEM::LogManager::verbose
@ verbose
Definition: LogManager.hpp:33
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::LogManager::warning
@ warning
Definition: LogManager.hpp:33
MoFEM::LogManager::addAttributes
static void addAttributes(LogManager::LoggerType &lg, const int bit=0)
Add attributes to logger.
Definition: LogManager.cpp:359