The interfaces in this group are used for debug and informational console output.
SMASH uses the einhard logging library for debug and info/warn/error output to stdout. This library builds upon the C++ ostream classes and thus uses stream operators for converting objects into a text representation.
The einhard library supports named output streams (which simply means they automatically add the name to the prefix string). We use this feature to define log areas in SMASH that can be configured independently. The einhard::Logger class supports two options: colorization and verbosity. For colorization we stay with the default of auto-detecting a color-terminal. For verbosity we use a Configuration object to set the verbosity of each area independently. This way we have control over the amount of debug output at runtime and without the need to touch the code/recompile.
To output something from your code do the following:
Note that LAreaName
needs to be declared within the smash namespace of the respective file in a form of (using PauliBlocking as an example area):
The einhard::Logger class supports two ways of writing to an output stream: Use stream operators or pass the list of objects for output as parameters. Thus
and
are equivalent (except for a small optimization opportunity in the former variant, that could make it slightly more efficient). You can see, though, that the former variant is more concise and often much easier to type than the stream operators.
Macros | |
#define | DECLARE_LOGAREA(id__, name__) |
Declares the necessary interface to identify a new log area. More... | |
#define | SMASH_SOURCE_LOCATION __FILE__ ":" + std::to_string(__LINE__) + " (" + __func__ + ')' |
Hackery that is required to output the location in the source code where the log statement occurs. More... | |
Typedefs | |
using | smash::LogArea::AreaTuple = std::tuple< Main, Experiment, Box, Collider, Sphere, Action, InputParser, ParticleType, FindScatter, Clock, DecayModes, Resonances, ScatterAction, Distributions, Propagation, Grid, List, Nucleus, Density, PauliBlocking, Tmn, Fpe, Lattice, Pythia, GrandcanThermalizer, CrossSections, Output, HyperSurfaceCrossing, InitialConditions, ScatterActionMulti, Configuration, Potentials, RootSolver > |
This type collects all existing log areas so they will be created with the correct log level automatically. More... | |
Functions | |
virtual void | smash::Action::format_debug_output (std::ostream &out) const =0 |
Writes information about this action to the out stream. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const ActionPtr &action) |
Convenience: dereferences the ActionPtr to Action. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const ActionList &actions) |
Writes multiple actions to the out stream. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const Angles &a) |
Creates output for an Angles object in the form "φ: 0.1294, cos ϑ: 0.423". More... | |
void | smash::DecayAction::format_debug_output (std::ostream &out) const override |
Writes information about this decay action to the out stream. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const EnergyMomentumTensor &Tmn) |
Prints out 4x4 tensor to the output stream. More... | |
std::ostream & | smash::operator<< (std::ostream &os, const FourVector &vec) |
Writes the four components of the vector to the output stream. More... | |
template<int w = 9, int p = w - 3, typename CharT , typename Traits > | |
std::basic_ostream< CharT, Traits > & | smash::field (std::basic_ostream< CharT, Traits > &s) |
Stream modifier to align the next object to a specific width w . More... | |
void | smash::create_all_loggers (Configuration config) |
Called from main() right after the Configuration object is fully set up to create all logger objects (as defined by LogArea::AreaTuple) with the correct area names and log levels. More... | |
einhard::LogLevel | smash::default_loglevel () |
void | smash::set_default_loglevel (einhard::LogLevel level) |
Set the default log level (what will be returned from subsequent default_loglevel calls). More... | |
template<typename T > | |
FormattingHelper< T > | smash::format (const T &value, const char *unit, int width=-1, int precision=-1) |
Acts as a stream modifier for std::ostream to output an object with an optional suffix string and with a given field width and precision. More... | |
static Node | YAML::convert< einhard::LogLevel >::encode (const einhard::LogLevel &x) |
Convert from einhard::LogLevel to YAML::Node. More... | |
static bool | YAML::convert< einhard::LogLevel >::decode (const Node &node, einhard::LogLevel &x) |
Convert from YAML::Node to einhard::LogLevel. More... | |
std::ostream & | smash::operator<< (std::ostream &s, const ParticleData &p) |
Writes the state of the particle to the output stream. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const ParticleList &particle_list) |
Writes a compact overview over the particles in the particle_list argument to the stream. More... | |
PrintParticleListDetailed | smash::detailed (const ParticleList &list) |
Request the ParticleList to be printed in full detail (i.e. More... | |
std::ostream & | smash::operator<< (std::ostream &out, const PrintParticleListDetailed &particle_list) |
Writes a detailed overview over the particles in the particle_list argument to the stream. More... | |
std::ostream & | smash::operator<< (std::ostream &is, const PdgCode &code) |
Writes the textual representation of the PDG code to the output stream. More... | |
std::ostream & | smash::operator<< (std::ostream &os, ProcessType process_type) |
Writes the textual representation of the process_type to the output stream os . More... | |
std::ostream & | smash::operator<< (std::ostream &os, const CollisionBranch &cbranch) |
Writes the textual representation of the Collision Branch cbranch to the output stream os . More... | |
void | smash::ScatterAction::format_debug_output (std::ostream &out) const override |
Writes information about this scatter action to the out stream. More... | |
std::ostream & | smash::operator<< (std::ostream &, const ThreeVector &) |
Writes the three components of the vector to the output stream. More... | |
Variables | |
const T & | smash::FormattingHelper< T >::value |
Value that is being formatted. More... | |
const int | smash::FormattingHelper< T >::width |
Output width. More... | |
const int | smash::FormattingHelper< T >::precision |
Precision that value is being formatted with. More... | |
const char *const | smash::FormattingHelper< T >::unit |
Unit that is attached at the end of value. More... | |
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > | smash::logg |
An array that stores all pre-configured Logger objects. More... | |
Friends | |
std::ostream & | smash::Action::operator<< (std::ostream &out, const Action &action) |
Dispatches formatting to the virtual Action::format_debug_output function. More... | |
std::ostream & | smash::BoxModus::operator<< (std::ostream &out, const BoxModus &m) |
Console output on startup of box specific parameters; writes the initial state for the box to the output stream. More... | |
std::ostream & | smash::ColliderModus::operator<< (std::ostream &, const ColliderModus &) |
Writes the initial state for the ColliderModus to the output stream. More... | |
std::ostream & | smash::Experiment< Modus >::operator<< (std::ostream &out, const Experiment &e) |
Writes the initial state for the Experiment to the output stream. More... | |
std::ostream & | smash::ListModus::operator<< (std::ostream &, const ListModus &) |
Writes the initial state for the List to the output stream. More... | |
std::ostream & | smash::FormattingHelper< T >::operator<< (std::ostream &out, const FormattingHelper &h) |
Nicely formatted output. More... | |
std::ostream & | smash::Nucleus::operator<< (std::ostream &, const Nucleus &) |
Writes the state of the Nucleus object to the output stream. More... | |
std::ostream & | smash::Particles::operator<< (std::ostream &out, const Particles &particles) |
Print effective mass and type name for all particles to the stream. More... | |
std::ostream & | smash::ParticleType::operator<< (std::ostream &out, const ParticleType &type) |
Writes all information about the particle type to the output stream. More... | |
std::ostream & | smash::SphereModus::operator<< (std::ostream &out, const SphereModus &m) |
Writes the initial state for the Sphere to the output stream. More... | |
#define DECLARE_LOGAREA | ( | id__, | |
name__ | |||
) |
#define SMASH_SOURCE_LOCATION __FILE__ ":" + std::to_string(__LINE__) + " (" + __func__ + ')' |
using smash::LogArea::AreaTuple = typedef std::tuple<Main, Experiment, Box, Collider, Sphere, Action, InputParser, ParticleType, FindScatter, Clock, DecayModes, Resonances, ScatterAction, Distributions, Propagation, Grid, List, Nucleus, Density, PauliBlocking, Tmn, Fpe, Lattice, Pythia, GrandcanThermalizer, CrossSections, Output, HyperSurfaceCrossing, InitialConditions, ScatterActionMulti, Configuration, Potentials, RootSolver> |
|
protectedpure virtual |
Writes information about this action to the out
stream.
[out] | out | out stream to be written to |
Implemented in smash::WallcrossingAction, smash::ThermalizationAction, smash::ScatterActionMulti, smash::ScatterAction, smash::HypersurfacecrossingAction, smash::FreeforallAction, and smash::DecayAction.
|
inline |
std::ostream & smash::operator<< | ( | std::ostream & | out, |
const ActionList & | actions | ||
) |
|
inline |
Creates output for an Angles object in the form "φ: 0.1294, cos ϑ: 0.423".
Definition at line 195 of file angles.h.
|
overrideprotectedvirtual |
Writes information about this decay action to the out
stream.
Implements smash::Action.
Definition at line 110 of file decayaction.cc.
std::ostream & smash::operator<< | ( | std::ostream & | out, |
const EnergyMomentumTensor & | Tmn | ||
) |
Prints out 4x4 tensor to the output stream.
[in] | out | Location of output |
[in] | Tmn | Energy-momentum tensor |
Definition at line 160 of file energymomentumtensor.cc.
std::ostream & smash::operator<< | ( | std::ostream & | os, |
const FourVector & | vec | ||
) |
Writes the four components of the vector to the output stream.
[in] | os | The ostream into which to output |
[in] | vec | The FourVector to write into os |
Definition at line 37 of file fourvector.cc.
|
inline |
Stream modifier to align the next object to a specific width w
.
w | The number of characters the field should have in the output. |
p | The floating precision. |
CharT | Character type of the output stream. |
Traits | Traits of the output stream. |
[in,out] | s | The output stream. |
Definition at line 30 of file iomanipulators.h.
void smash::create_all_loggers | ( | Configuration | config | ) |
Called from main() right after the Configuration object is fully set up to create all logger objects (as defined by LogArea::AreaTuple) with the correct area names and log levels.
config | A configuration object with the log area names as toplevel keys. |
Definition at line 119 of file logging.cc.
einhard::LogLevel smash::default_loglevel | ( | ) |
Definition at line 22 of file logging.cc.
void smash::set_default_loglevel | ( | einhard::LogLevel | level | ) |
Set the default log level (what will be returned from subsequent default_loglevel calls).
level | The new log level. See einhard::LogLevel. |
Definition at line 24 of file logging.cc.
FormattingHelper<T> smash::format | ( | const T & | value, |
const char * | unit, | ||
int | width = -1 , |
||
int | precision = -1 |
||
) |
Acts as a stream modifier for std::ostream to output an object with an optional suffix string and with a given field width and precision.
T | Value that is being formatted. |
value | The object to be written to the stream. |
unit | An optional suffix string, typically used for a unit. May be nullptr. |
width | The field width to use for value . |
precision | The precision to use for value . |
|
inlinestatic |
Convert from einhard::LogLevel to YAML::Node.
x | Log level. |
Definition at line 243 of file logging.h.
|
inlinestatic |
Convert from YAML::Node to einhard::LogLevel.
[in] | node | YAML node. |
[out] | x | Where the corresponding log level will be stored if the conversion was successful. |
Definition at line 255 of file logging.h.
std::ostream & smash::operator<< | ( | std::ostream & | s, |
const ParticleData & | p | ||
) |
Writes the state of the particle to the output stream.
Definition at line 122 of file particledata.cc.
std::ostream & smash::operator<< | ( | std::ostream & | out, |
const ParticleList & | particle_list | ||
) |
Writes a compact overview over the particles in the particle_list
argument to the stream.
Definition at line 133 of file particledata.cc.
|
inline |
Request the ParticleList to be printed in full detail (i.e.
one full ParticleData printout per line).
Definition at line 500 of file particledata.h.
std::ostream & smash::operator<< | ( | std::ostream & | out, |
const PrintParticleListDetailed & | particle_list | ||
) |
Writes a detailed overview over the particles in the particle_list
argument to the stream.
This overload is selected via the function detailed.
Definition at line 148 of file particledata.cc.
std::ostream & smash::operator<< | ( | std::ostream & | is, |
const PdgCode & | code | ||
) |
Writes the textual representation of the PDG code to the output stream.
Definition at line 88 of file pdgcode.cc.
std::ostream & smash::operator<< | ( | std::ostream & | os, |
ProcessType | process_type | ||
) |
Writes the textual representation of the process_type
to the output stream os
.
Definition at line 92 of file processbranch.cc.
std::ostream & smash::operator<< | ( | std::ostream & | os, |
const CollisionBranch & | cbranch | ||
) |
Writes the textual representation of the Collision Branch cbranch
to the output stream os
.
Definition at line 55 of file processbranch.cc.
|
overrideprotectedvirtual |
Writes information about this scatter action to the out
stream.
Implements smash::Action.
Definition at line 745 of file scatteraction.cc.
std::ostream & smash::operator<< | ( | std::ostream & | out, |
const ThreeVector & | v | ||
) |
Writes the three components of the vector to the output stream.
Definition at line 16 of file threevector.cc.
const T& smash::FormattingHelper< T >::value |
const int smash::FormattingHelper< T >::width |
const int smash::FormattingHelper< T >::precision |
const char* const smash::FormattingHelper< T >::unit |
std::array< einhard::Logger<>, std::tuple_size< LogArea::AreaTuple >::value > smash::logg |
An array that stores all pre-configured Logger objects.
The objects can be accessed via the logger function.
To access its elements use logg[LAreaName]
where AreaName is the respective areas name declared in loggin.h
. Note that LAreaName
needs to be declared within the smash namespace of the respective file in a form of (using PauliBlocking as an example area):
For further documentation see logging.h
.
Definition at line 39 of file logging.cc.
|
friend |
Dispatches formatting to the virtual Action::format_debug_output function.
|
friend |
Console output on startup of box specific parameters; writes the initial state for the box to the output stream.
[in] | out | The ostream into which to output |
[in] | m | The BoxModus object to write into out |
Definition at line 32 of file boxmodus.cc.
|
friend |
Writes the initial state for the ColliderModus to the output stream.
[in] | out | The ostream into which to output |
[in] | m | The ColliderModus object to write into out |
Definition at line 273 of file collidermodus.cc.
|
friend |
Writes the initial state for the Experiment to the output stream.
It automatically appends the output of the current Modus.
Definition at line 713 of file experiment.h.
|
friend |
Writes the initial state for the List to the output stream.
[in] | out | The ostream into which to output |
[in] | m | The ListModus object to write into out |
Definition at line 75 of file listmodus.cc.
|
friend |
Nicely formatted output.
out | Output stream |
h | FormattingHelper with given output parameters. |
|
friend |
Writes the state of the Nucleus object to the output stream.
Definition at line 512 of file nucleus.cc.
|
friend |
Print effective mass and type name for all particles to the stream.
[in] | out | The ostream into which to output |
[in] | particles | The Particles object to write into out |
Definition at line 148 of file particles.cc.
|
friend |
Writes all information about the particle type to the output stream.
[out] | out | The ostream into which to output |
[in] | type | The ParticleType object to write into out |
Definition at line 760 of file particletype.cc.
|
friend |
Writes the initial state for the Sphere to the output stream.
[in] | out | The ostream into which to output |
[in] | m | The SphereModus object to write into out |
Definition at line 72 of file spheremodus.cc.