Celeritas  0.5.0-86+4a8eea4
Public Member Functions | Static Public Member Functions | List of all members
celeritas::Logger Class Reference

Create a log message to be printed based on output/verbosity sttings. More...

#include <Logger.hh>

Public Types

Type aliases
using Message = detail::LoggerMessage
 

Public Member Functions

 Logger (LogHandler handle)
 Construct with handler. More...
 
Message operator() (LogProvenance &&prov, LogLevel lev)
 Create a logger that flushes its contents when it destructs. More...
 
void level (LogLevel lev)
 Set the minimum logging verbosity.
 
LogLevel level () const
 Get the current logging verbosity.
 

Static Public Member Functions

static constexpr LogLevel default_level ()
 Get the default log level.
 

Detailed Description

Create a log message to be printed based on output/verbosity sttings.

This should generally be called by the world_logger and self_logger functions below. The call operator() returns an object that should be streamed into in order to create a log message.

This object is assignable, so to replace the default log handler with a different one, you can call

world_logger = Logger(my_handler);
Logger(LogHandler handle)
Construct with handler.
Definition: corecel/io/Logger.cc:99
Logger & world_logger()
Parallel-enabled logger: print only on "main" process.
Definition: corecel/io/Logger.cc:178

When using with MPI, the world_logger global objects are different on each process: rank 0 will have a handler that outputs to screen, and the other ranks will have a "null" handler that suppresses all log output.

Constructor & Destructor Documentation

◆ Logger()

celeritas::Logger::Logger ( LogHandler  handle)
explicit

Construct with handler.

A null handler will silence the logger.

Member Function Documentation

◆ operator()()

auto celeritas::Logger::operator() ( LogProvenance &&  prov,
LogLevel  lev 
)
inline

Create a logger that flushes its contents when it destructs.

It's assumed that log messages will be relatively unlikely (and expensive anyway), so we mark as CELER_UNLIKELY to optimize for the no-logging case.


The documentation for this class was generated from the following files: