16 XMLTag tagLog(*
this,
"log", XMLTag::OCCUR_NOT_OR_ONCE);
17 tagLog.setDocumentation(
"Configures logging sinks based on Boost log.");
19 auto attrLogEnabled = makeXMLAttribute(
"enabled",
true)
21 "Disable sinks if you prefer to handle preCICE logs in your application using boost.log.");
23 tagLog.addAttribute(attrLogEnabled);
25 XMLTag tagSink(*
this,
"sink", XMLTag::OCCUR_ARBITRARY);
26 tagSink.setDocumentation(
"Contains the configuration of a single log sink, which allows fine grained control of what to log where. "
27 "Available attributes in filter and format strings are `%TimeStamp%`, `%Runtime%`, `%Severity%`, `%ColorizedSeverity%`, `%File%`, `%Line%`, `%Function%`, `%Module%`, `%Rank%`, and `%Participant%`. "
28 "The boolean attribute `%preCICE%` is `true` for all log entries originating from preCICE.");
29 auto attrType = XMLAttribute<std::string>(
"type")
30 .setDocumentation(
"The type of sink.")
31 .setOptions({
"stream",
"file"})
33 tagSink.addAttribute(attrType);
35 auto attrOutput = XMLAttribute<std::string>(
"output")
36 .setDocumentation(
"Depends on the type of the sink. For streams, this can be stdout or stderr. For files, this is the filename.")
38 tagSink.addAttribute(attrOutput);
40 auto attrFormat = XMLAttribute<std::string>(
"format")
41 .setDocumentation(
"Boost Log Format String")
43 tagSink.addAttribute(attrFormat);
45 auto attrFilter = XMLAttribute<std::string>(
"filter")
46 .setDocumentation(
"Boost Log Filter String")
48 tagSink.addAttribute(attrFilter);
50 auto attrEnabled = makeXMLAttribute(
"enabled",
true)
52 tagSink.addAttribute(attrEnabled);
54 tagLog.addSubtag(tagSink);
#define PRECICE_TRACE(...)
precice::logging::LoggingConfiguration _logconfig
virtual void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &tag)
Callback at end of XML tag and at end of subtag.
virtual void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &tag)
Callback at begin of XML tag.
LogConfiguration(xml::XMLTag &parent)
XMLAttribute & setDocumentation(std::string documentation)
Sets a documentation string for the attribute.
Represents an XML tag to be configured automatically.
std::string getStringAttributeValue(const std::string &name, std::optional< std::string > default_value=std::nullopt) const
bool getBooleanAttributeValue(const std::string &name, std::optional< bool > default_value=std::nullopt) const
const std::string & getName() const
Returns name (without namespace).
const std::string & getFullName() const
Returns full name consisting of xml namespace + ":" + name.
XMLTag & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
void setupLogging(LoggingConfiguration configs, bool enabled)
Configures the logging from a LoggingConfiguration.
Holds the configuration for one logging backend (sink) and takes care of default values.
void setEnabled(bool enabled)
Sets weather the sink is enabled or disabled.
static const std::string default_filter
void setOption(std::string key, std::string value)
Sets on option, overwrites default values.
static const std::string default_type
static const std::string default_output
static const std::string default_formatter
Tightly coupled to the parameters of Participant()