27 class HauserFeshbachDecay;
33 std::ostream& operator<<(std::ostream& out,
36 std::ostream& operator<<(std::ostream& out,
const marley::Parity& p);
37 std::ostream& operator<<(std::ostream& out,
const marley::Target& t);
54 enum class LogLevel { DISABLED, ERROR, WARNING, INFO, DEBUG };
60 const char* loglevel_to_str(
LogLevel lev);
66 friend class OutStreamVector;
88 OutStream(std::shared_ptr<std::ostream> os,
LogLevel lev,
111 std::shared_ptr<std::ostream> stream_;
123 class OutStreamVector :
public std::vector<OutStream> {
126 OutStreamVector() : std::vector<OutStream>() {}
128 template<
typename OutputType> OutStreamVector&
129 operator<<(
const OutputType& ot);
135 OutStreamVector& operator<<(std::ostream& (*manip)(std::ostream&));
138 OutStreamVector& operator<<(std::ios_base& (*manip)(std::ios_base&));
146 Message(OutStreamVector& vec) : osvec_( vec ) {}
152 template<
typename OutputType> Message&&
153 operator<<(
const OutputType& ot)
156 return std::move( *
this );
160 OutStreamVector& osvec_;
166 Logger(
bool log_enabled =
true);
181 void add_stream(std::shared_ptr<std::ostream> stream,
182 LogLevel level = LogLevel::WARNING);
191 LogLevel level = LogLevel::WARNING);
198 void enable(
bool log_enabled =
true);
212 bool has_stream(
const std::ostream& stream)
const;
241 OutStream* find_stream(
const std::ostream* os,
bool& stream_enabled,
246 const OutStream* get_stream(
const std::ostream* os)
const;
250 OutStream* get_stream(
const std::ostream* os);
254 OutStreamVector streams_;
268 template<
typename OutputType> marley::Logger::OutStreamVector&
269 marley::Logger::OutStreamVector::operator<<(
const OutputType& ot)
271 for (
auto s : *
this)
if (s.enabled_ && s.stream_) *(s.stream_) << ot;
276 inline auto MARLEY_LOG_ERROR() {
280 inline auto MARLEY_LOG_WARNING() {
284 inline auto MARLEY_LOG_INFO() {
288 inline auto MARLEY_LOG_DEBUG() {
Monte Carlo implementation of the Hauser-Feshbach statistical model for decays of highly-excited nucl...
Definition: HauserFeshbachDecay.hh:31
Simple singleton logging class.
Definition: Logger.hh:45
static Logger & Instance()
Get the singleton instance of the Logger class.
Definition: Logger.cc:109
Logger(const Logger &)=delete
Deleted copy constructor.
Logger & operator=(Logger &&)=delete
Deleted move assignment operator.
Message log(LogLevel lev=LogLevel::WARNING)
Prepare the Logger to receive a log message via the << stream operator.
Definition: Logger.cc:182
LogLevel
Defines the logging levels recognized by the marley::Logger.
Definition: Logger.hh:54
Logger & operator=(const Logger &)=delete
Deleted copy assignment operator.
void clear_streams()
Clear the vector of streams that receive Logger output.
Definition: Logger.cc:87
void disable()
Disable the Logger.
Definition: Logger.hh:266
void add_stream(std::shared_ptr< std::ostream > stream, LogLevel level=LogLevel::WARNING)
Add a std::ostream to the vector of streams that will receive Logger output.
Definition: Logger.cc:158
void enable(bool log_enabled=true)
Enable or disable the Logger.
Definition: Logger.cc:177
void newline()
Send a newline character to all output streams ignoring logging level settings.
Definition: Logger.cc:83
void flush()
Flush all output streams associated with the Logger.
Definition: Logger.cc:79
bool has_stream(const std::ostream &stream) const
Returns true if stream is already registered with the Logger, or false otherwise.
Definition: Logger.cc:114
Logger(Logger &&)=delete
Deleted move constructor.
Type-safe representation of a parity value (either +1 or -1)
Definition: Parity.hh:25
An atomic target for a lepton scattering reaction.
Definition: TargetAtom.hh:26
Description of a macroscopic target for scattering reactions.
Definition: Target.hh:32