Celeritas  0.5.0-56+6b053cd
Classes | Macros | Functions
corecel/io/Logger.hh File Reference
#include <string>
#include <utility>
#include "corecel/Config.hh"
#include "LoggerTypes.hh"
#include "detail/LoggerMessage.hh"

Classes

class  celeritas::Logger
 Create a log message to be printed based on output/verbosity sttings. More...
 

Macros

#define CELER_CODE_PROVENANCE
 Inject the source code provenance (current file and line) More...
 
#define CELER_LOG(LEVEL)
 Return a LogMessage object for streaming into at the given level. More...
 
#define CELER_LOG_LOCAL(LEVEL)
 Like CELER_LOG but for code paths that may only happen on a single process or thread. More...
 

Functions

LogLevel celeritas::log_level_from_env (std::string const &level_env, LogLevel default_lev)
 Get the log level from an environment variable.
 
LogLevel celeritas::log_level_from_env (std::string const &level_env)
 Get the log level from an environment variable. More...
 
Logger celeritas::make_default_world_logger ()
 Create a default logger using the world communicator. More...
 
Logger celeritas::make_default_self_logger ()
 Create a default logger using the local communicator. More...
 
Logger & celeritas::world_logger ()
 Parallel-enabled logger: print only on "main" process. More...
 
Logger & celeritas::self_logger ()
 Serial logger: print on every process that calls it. More...
 

Macro Definition Documentation

◆ CELER_CODE_PROVENANCE

#define CELER_CODE_PROVENANCE
Value:
{ \
__FILE__, __LINE__ \
}
Stand-in for a more complex class for the "provenance" of data.
Definition: LoggerTypes.hh:45

Inject the source code provenance (current file and line)

◆ CELER_LOG

#define CELER_LOG (   LEVEL)
Value:
::celeritas::world_logger()(CELER_CODE_PROVENANCE, \
::celeritas::LogLevel::LEVEL)
#define CELER_CODE_PROVENANCE
Inject the source code provenance (current file and line)
Definition: corecel/io/Logger.hh:26

Return a LogMessage object for streaming into at the given level.

The regular CELER_LOG call is for code paths that happen uniformly in parallel.

The logger will only format and print messages. It is not responsible for cleaning up the state or exiting an app.

CELER_LOG(debug) << "Don't print this in general";
CELER_LOG(warning) << "You may want to reconsider your life choices";
CELER_LOG(critical) << "Caught a fatal exception: " << e.what();
#define CELER_LOG(LEVEL)
Return a LogMessage object for streaming into at the given level.
Definition: corecel/io/Logger.hh:48

◆ CELER_LOG_LOCAL

#define CELER_LOG_LOCAL (   LEVEL)
Value:
::celeritas::self_logger()(CELER_CODE_PROVENANCE, \
::celeritas::LogLevel::LEVEL)

Like CELER_LOG but for code paths that may only happen on a single process or thread.

Use sparingly.

Function Documentation

◆ log_level_from_env()

LogLevel celeritas::log_level_from_env ( std::string const &  level_env)

Get the log level from an environment variable.

Default to Logger::default_level, which is 'info'.

◆ make_default_self_logger()

Logger celeritas::make_default_self_logger ( )

Create a default logger using the local communicator.

If MPI is enabled, this will prepend the local process index to the message.

◆ make_default_world_logger()

Logger celeritas::make_default_world_logger ( )

Create a default logger using the world communicator.

The result prints only on one processor in the world communicator group. This function can be useful when resetting a test harness.

◆ self_logger()

Logger & celeritas::self_logger ( )

Serial logger: print on every process that calls it.

Setting the "CELER_LOG_LOCAL" environment variable to "debug", "info", "error", etc. will change the default log level.

◆ world_logger()

Logger & celeritas::world_logger ( )

Parallel-enabled logger: print only on "main" process.

Setting the "CELER_LOG" environment variable to "debug", "info", "error", etc. will change the default log level.