11#include <framework/logging/LogConfig.h>
18#include <boost/lexical_cast.hpp>
32 template<
class TVarType>
33 LogVar(
const std::string& name,
const TVarType& v) :
131 typedef std::basic_ostream<std::stringstream::char_type, std::stringstream::traits_type >
__basic_ostream_type;
154 explicit LogVariableStream(std::string
const& text, std::map<std::string, std::string> variables = {})
157 for (
auto const& kv : variables) {
193 template<
class TText>
205 template<
class PODTYPE>
235 std::string
str(
bool showVariables =
true)
const
243 std::stringstream tmpBuffer;
247 tmpBuffer << std::endl <<
"\t" << v.getName() <<
" = " << v.getValue();
249 return tmpBuffer.str();
ELogLevel
Definition of the supported log levels.
@ c_Default
Default: use globally configured log level.
ELogRealm
Definition of the supported execution realms.
Class to modify the log level dependent on the execution realm.
Belle2::LogConfig::ELogLevel getLogLevel() const
Returns the log level.
Belle2::LogConfig::ELogRealm m_realm
Realm for the conditional log level.
Belle2::LogConfig::ELogRealm getRealm() const
Returns the realm.
LogModRealm(Belle2::LogConfig::ELogRealm realm, Belle2::LogConfig::ELogLevel logLevel)
Constructor of a realm dependent modification of the log level.
Belle2::LogConfig::ELogLevel m_logLevel
Realm dependent log level.
Class to store variables with their name which were sent to the logging service.
std::string getValue() const
Returns the value stored for this variable.
LogVar(const std::string &name, const TVarType &v)
Constructor which accepts any type as value and relies on boost lexical cast.
bool operator==(const LogVar &lv) const
Custom comparison operator.
std::string getName() const
Returns the name stored for this variable.
std::string m_value
String conversion of the value.
std::string m_name
Stores the name of the variable.
Specialized implementation of an ostream-like class where the << operator can be used to insert value...
const std::vector< LogVar > & getVariables() const
Return the list of all defined variables.
std::string getMessage() const
Return the constant message part without the variables.
LogVariableStream(std::string const &text, std::map< std::string, std::string > variables={})
Constructor which sets an initial text for this stream.
Belle2::LogConfig::ELogLevel m_logLevelOverride
Adjusted log level.
std::vector< LogVar > m_variables
List of LogVars which were accepted so far.
LogVariableStream(LogVariableStream &&)=default
Provide default move constructor.
LogVariableStream & operator<<(__basic_ostream_type &(*__pf)(__basic_ostream_type &))
operator override for ostream modifier functions like std::endl who are directly applied to the under...
LogVariableStream & operator<<(LogVar const &var)
Operator override which stores the LogVar information instead of putting it directly in the sstream.
LogVariableStream(const LogVariableStream &other)
Implement custom copy-constructor, because stringstream's one is deleted.
void adjustLogLevel(Belle2::LogConfig::ELogLevel &logLevel) const
Adjust the log level in case of a realm dependent modification.
std::stringstream m_stringStream
All non-LogVar items are directly forwarded to this stringstream.
std::basic_ostream< std::stringstream::char_type, std::stringstream::traits_type > __basic_ostream_type
basic_ofstream which is used with ostream's utility functions
LogVariableStream()=default
Default constructor with empty text and no variables.
std::enable_if< std::is_fundamental< PODTYPE >::value, LogVariableStream & >::type operator<<(PODTYPE pod)
Templated operator which will be used for POD types (especially integers) and uses by-value.
LogVariableStream & operator=(const LogVariableStream &lvs)
Custom assignment-operator, thanks to stringsream's non-copy policy.
std::enable_if< notstd::is_fundamental< TText >::value, LogVariableStream & >::type operator<<(TText const &text)
Templated operator which will be used for all non-fundamental types.
std::string str(bool showVariables=true) const
Return the content of the stream as string.
bool operator==(const LogVariableStream &lvs) const
Custom comparison operator.