Celeritas 0.7.0-3+develop.835656ac1
Loading...
Searching...
No Matches
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 settings. More...

#include <Logger.hh>

Public Types

Type aliases
using Message = detail::LoggerMessage
 

Public Member Functions

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

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 settings.

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);
Create a log message to be printed based on output/verbosity settings.
Definition corecel/io/Logger.hh:93
Logger & world_logger()
App-level logger: print only on "main" process.
Definition corecel/io/Logger.cc:68

When using with MPI, set a null handle to world_logger on all processes other than rank 0, or use LocalMpiHandler on each process.

Todo:
Replace the back-end with spdlog to reduce maintenance burden and improve flexibility.

Member Function Documentation

◆ operator()()

auto celeritas::Logger::operator() ( LogProvenance &&  prov,
LogLevel  lev 
) const
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: