Skip to content
Snippets Groups Projects
Commit c84bc2eb authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

update DefaultLogger usage

parent ae99f039
No related branches found
No related tags found
1 merge request!68dailywork-ftschindler
Pipeline #69557 failed
......@@ -92,7 +92,7 @@ DefaultLogger& DefaultLogger::operator=(const DefaultLogger& other)
void DefaultLogger::enable(const std::string& prfx)
{
state = {true, true, true};
state = default_logger_state();
if (!prfx.empty()) {
prefix = prfx;
copy_count = 0;
......@@ -143,7 +143,7 @@ void DefaultLogger::state_and(const std::array<bool, 3>& other_state)
void DefaultLogger::disable()
{
state = {false, false, false};
state = {{false, false, false}};
}
std::ostream& DefaultLogger::info()
......
......@@ -47,6 +47,13 @@ DUNE_EXPORT inline const Timer& SecondsSinceStartup()
}
DUNE_EXPORT inline std::array<bool, 3>& default_logger_state()
{
static std::array<bool, 3> state_{{true, false, true}};
return state_;
}
/**
* \brief A logging manager that provides info, debug and warning streams
*/
......@@ -73,8 +80,8 @@ public:
size_t copy_count;
DefaultLogger(const std::string& prfx = "",
const std::array<bool, 3>& initial_state = {true, true, true},
const std::array<std::string, 3>& colors = {"blue", "darkgray", "red"},
const std::array<bool, 3>& initial_state = default_logger_state(),
const std::array<std::string, 3>& colors = {{"blue", "darkgray", "red"}},
bool global_timer = true);
DefaultLogger(const DefaultLogger&);
......@@ -163,7 +170,7 @@ class WithLogger
public:
mutable DefaultLogger logger;
WithLogger(const std::string& id, const std::array<bool, 3>& initial_state = {true, true, true})
WithLogger(const std::string& id, const std::array<bool, 3>& initial_state = {{true, true, true}})
: logger(id, initial_state)
{
LOG_(debug) << "WithLogger(this=" << this << ")" << std::endl;
......
......@@ -86,11 +86,12 @@ public:
CombinedGridFunction(const LeftType& left,
const RightType& right,
const std::string nm = "",
const std::string& logging_prefix = "")
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(left.parameter_type() + right.parameter_type(),
logging_prefix.empty() ? Common::to_camel_case(get_combination_name(comb{}) + "GridFunction")
: logging_prefix,
logging_prefix.empty())
logging_state)
, left_(left.copy_as_grid_function())
, right_(right.copy_as_grid_function())
, name_(nm.empty() ? "(" + left_->name() + GetCombination<comb>::symbol() + right_->name() + ")" : nm)
......@@ -102,11 +103,12 @@ public:
CombinedGridFunction(LeftType*&& left,
RightType*&& right,
const std::string nm = "",
const std::string& logging_prefix = "")
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(left->parameter_type() + right->parameter_type(),
logging_prefix.empty() ? Common::to_camel_case(get_combination_name(comb{}) + "GridFunction")
: logging_prefix,
logging_prefix.empty())
logging_state)
, left_(std::move(left))
, right_(std::move(right))
, name_(nm.empty() ? "(" + left_->name() + GetCombination<comb>::symbol() + right_->name() + ")" : nm)
......@@ -126,8 +128,7 @@ public:
std::unique_ptr<LocalFunctionType> local_function() const override final
{
LOG_(debug) << Common::to_camel_case(get_combination_name(comb{}) + "GridFunction") + "::local_function()"
<< std::endl;
LOG_(debug) << "local_function()" << std::endl;
using LeftLF = typename LeftType::LocalFunctionType;
using RightLF = typename RightType::LocalFunctionType;
return std::make_unique<CombinedElementFunction<LeftLF, RightLF, comb>>(std::move(left_->local_function()),
......
......@@ -212,13 +212,12 @@ public:
Functions::DifferenceFunction<ThisType, ThisType> operator-(const ThisType& other) const
{
return Functions::DifferenceFunction<ThisType, ThisType>(
*this, other, "(" + this->name() + " - " + other.name() + ")");
return Functions::DifferenceFunction<ThisType, ThisType>(*this, other, this->name() + " - " + other.name());
}
Functions::SumFunction<ThisType, ThisType> operator+(const ThisType& other) const
{
return Functions::SumFunction<ThisType, ThisType>(*this, other, "(" + this->name() + " + " + other.name() + ")");
return Functions::SumFunction<ThisType, ThisType>(*this, other, this->name() + " + " + other.name());
}
template <class OtherType>
......@@ -228,7 +227,7 @@ public:
operator*(const OtherType& other) const
{
return Functions::ProductFunction<ThisType, as_function_interface_t<OtherType>>(
*this, other, "(" + this->name() + "*" + other.name() + ")");
*this, other, "(" + this->name() + ")*(" + other.name() + ")");
}
template <class OtherType>
......@@ -238,7 +237,7 @@ public:
operator/(const OtherType& other) const
{
return Functions::FractionFunction<ThisType, as_function_interface_t<OtherType>>(
*this, other, "(" + this->name() + "/" + other.name() + ")");
*this, other, "(" + this->name() + ")/(" + other.name() + ")");
}
/**
......
......@@ -105,7 +105,7 @@ private:
public:
GridFunctionInterface(const Common::ParameterType& param_type = {},
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {false, false, true})
const std::array<bool, 3>& logging_state = {{false, false, true}})
: Common::ParametricInterface(param_type)
, Logger(logging_prefix.empty() ? "GridFunctionInterface" : logging_prefix, logging_state)
{
......@@ -178,25 +178,23 @@ public:
Functions::DifferenceGridFunction<ThisType, ThisType> operator-(const ThisType& other) const
{
std::string derived_logging_prefix = "";
if (this->logger.debug_enabled || other.logger.debug_enabled) {
derived_logging_prefix = "(" + this->logger.prefix + " - " + other.logger.prefix + ")";
this->logger.debug() << logging_id() << "::operator-(other=" << &other << ")" << std::endl;
}
return Functions::DifferenceGridFunction<ThisType, ThisType>(
*this, other, "(" + this->name() + " - " + other.name() + ")", derived_logging_prefix);
}
LOG_(debug) << "operator-(other=" << &other << ")" << std::endl;
return Functions::DifferenceGridFunction<ThisType, ThisType>(*this,
other,
this->name() + " - " + other.name(),
this->logger.prefix + " - " + other.logger.prefix,
this->logger.get_state_or(other.logger.state));
} // ... operator-(...)
Functions::SumGridFunction<ThisType, ThisType> operator+(const ThisType& other) const
{
std::string derived_logging_prefix = "";
if (this->logger.debug_enabled || other.logger.debug_enabled) {
derived_logging_prefix = "(" + this->logger.prefix + " - " + other.logger.prefix + ")";
this->logger.debug() << logging_id() << "::operator+(other=" << &other << ")" << std::endl;
}
return Functions::SumGridFunction<ThisType, ThisType>(
*this, other, "(" + this->name() + " + " + other.name() + ")", derived_logging_prefix);
}
LOG_(debug) << "operator+(other=" << &other << ")" << std::endl;
return Functions::SumGridFunction<ThisType, ThisType>(*this,
other,
this->name() + " + " + other.name(),
this->logger.prefix + " + " + other.logger.prefix,
this->logger.get_state_or(other.logger.state));
} // ... operator+(...)
template <class OtherType>
std::enable_if_t<is_grid_function<OtherType>::value
......@@ -204,14 +202,14 @@ public:
Functions::ProductGridFunction<ThisType, as_grid_function_interface_t<OtherType>>>
operator*(const OtherType& other) const
{
std::string derived_logging_prefix = "";
if (this->logger.debug_enabled || other.logger.debug_enabled) {
derived_logging_prefix = "(" + this->logger.prefix + "*" + other.logger.prefix + ")";
this->logger.debug() << logging_id() << "::operator*(other=" << &other << ")" << std::endl;
}
LOG_(debug) << "operator*(other=" << &other << ")" << std::endl;
return Functions::ProductGridFunction<ThisType, as_grid_function_interface_t<OtherType>>(
*this, other, "(" + this->name() + "*" + other.name() + ")", derived_logging_prefix);
}
*this,
other,
"(" + this->name() + ")*(" + other.name() + ")",
"(" + this->logger.prefix + ")*(" + other.logger.prefix + ")",
this->logger.get_state_or(other.logger.state));
} // ... operator*(...)
template <class OtherType>
std::enable_if_t<is_grid_function<OtherType>::value
......@@ -219,14 +217,14 @@ public:
Functions::FractionGridFunction<ThisType, as_grid_function_interface_t<OtherType>>>
operator/(const OtherType& other) const
{
std::string derived_logging_prefix = "";
if (this->logger.debug_enabled || other.logger.debug_enabled) {
derived_logging_prefix = "(" + this->logger.prefix + "/" + other.logger.prefix + ")";
this->logger.debug() << logging_id() << "::operator/(other=" << &other << ")" << std::endl;
}
return Functions::FractionGridFunction<ThisType, as_grid_function_interface_t<OtherType>>(
*this, other, "(" + this->name() + "/" + other.name() + ")", derived_logging_prefix);
}
LOG_(debug) << "operator/(other=" << &other << ")" << std::endl;
return Functions::ProductGridFunction<ThisType, as_grid_function_interface_t<OtherType>>(
*this,
other,
"(" + this->name() + ")/(" + other.name() + ")",
"(" + this->logger.prefix + ")/(" + other.logger.prefix + ")",
this->logger.get_state_or(other.logger.state));
} // ... operator/(...)
/// \}
......
......@@ -74,8 +74,9 @@ public:
using DomainType = Common::FieldVector<DomainFieldType, dimDomain>;
using WorldType = Common::FieldVector<DomainFieldType, dimWorld>;
BoundaryInfo(const std::string& log_prefix = "", const bool logging_disabled = true)
: Logger(log_prefix.empty() ? "BoundaryInfo" : log_prefix, logging_disabled)
BoundaryInfo(const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: Logger(logging_prefix.empty() ? "BoundaryInfo" : logging_prefix, logging_state)
{}
BoundaryInfo(const ThisType&) = default;
......
......@@ -159,9 +159,9 @@ public:
*/
NormalBasedBoundaryInfo(const DomainFieldType tol = 1e-10,
BoundaryType*&& default_boundary_type = new NoBoundary(),
const std::string& logging_prefix = "")
: BaseType(logging_prefix.empty() ? "NormalBasedBoundaryInfo" : logging_prefix,
/*logging_disabled=*/logging_prefix.empty())
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(logging_prefix.empty() ? "NormalBasedBoundaryInfo" : logging_prefix, logging_state)
, tol_(tol)
, default_boundary_type_(std::move(default_boundary_type))
{
......
......@@ -128,7 +128,7 @@ public:
mutable Common::DefaultLogger logger;
IntersectionFilter(const std::string& logging_prefix = "xt.grid.intersectionfilter",
const std::array<bool, 3>& logging_state = {false, false, true})
const std::array<bool, 3>& logging_state = {{false, false, true}})
: logger(logging_prefix, logging_state)
{}
......
......@@ -555,18 +555,18 @@ public:
*/
explicit CustomBoundaryIntersections(const BoundaryInfo<IntersectionType>& boundary_info,
BoundaryType*&& boundary_type,
const std::string& logging_prefix = "")
: BaseType(logging_prefix.empty() ? "xt.grid.customboundaryintersections" : logging_prefix,
/*logging_disabled=*/logging_prefix.empty())
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(logging_prefix.empty() ? "xt.grid.customboundaryintersections" : logging_prefix, logging_state)
, boundary_info_(boundary_info)
, boundary_type_(boundary_type)
{}
explicit CustomBoundaryIntersections(const BoundaryInfo<IntersectionType>& boundary_info,
const std::shared_ptr<BoundaryType>& boundary_type,
const std::string& logging_prefix = "")
: BaseType(logging_prefix.empty() ? "xt.grid.customboundaryintersections" : logging_prefix,
/*logging_disabled=*/logging_prefix.empty())
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(logging_prefix.empty() ? "xt.grid.customboundaryintersections" : logging_prefix, logging_state)
, boundary_info_(boundary_info)
, boundary_type_(boundary_type)
{}
......
......@@ -41,9 +41,9 @@ public:
*/
BoundaryDetectorFunctor(const BoundaryInfo<IntersectionType>& boundary_info,
BoundaryType*&& boundary_type_ptr,
const std::string& logging_prefix = "")
: BaseType(logging_prefix.empty() ? "BoundaryDetectorFunctor" : logging_prefix,
/*logging_disabled=*/logging_prefix.empty())
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(logging_prefix.empty() ? "BoundaryDetectorFunctor" : logging_prefix, logging_state)
, Propagator(this)
, boundary_info_(boundary_info)
, boundary_type_(boundary_type_ptr)
......@@ -55,9 +55,9 @@ public:
BoundaryDetectorFunctor(const BoundaryInfo<IntersectionType>& boundary_info,
const BoundaryType& boundary_type,
const std::string& logging_prefix = "")
: BaseType(logging_prefix.empty() ? "BoundaryDetectorFunctor" : logging_prefix,
/*logging_disabled=*/logging_prefix.empty())
const std::string& logging_prefix = "",
const std::array<bool, 3>& logging_state = {{false, false, true}})
: BaseType(logging_prefix.empty() ? "BoundaryDetectorFunctor" : logging_prefix, logging_state)
, Propagator(this)
, boundary_info_(boundary_info)
, boundary_type_(boundary_type.copy())
......
......@@ -47,7 +47,7 @@ public:
using GV = GridViewType;
using E = ElementType;
ElementFunctor(const std::string& log_prefix = "", const std::array<bool, 3>& logging_state = {false, false, true})
ElementFunctor(const std::string& log_prefix = "", const std::array<bool, 3>& logging_state = {{false, false, true}})
: Common::WithLogger<ElementFunctor<GL>>(log_prefix.empty() ? "ElementFunctor" : log_prefix, logging_state)
{}
......@@ -94,7 +94,7 @@ public:
using I = IntersectionType;
IntersectionFunctor(const std::string& log_prefix = "",
const std::array<bool, 3>& logging_state = {false, false, true})
const std::array<bool, 3>& logging_state = {{false, false, true}})
: Common::WithLogger<IntersectionFunctor<GL>>(log_prefix.empty() ? "IntersectionFunctor" : log_prefix,
logging_state)
{}
......@@ -148,7 +148,7 @@ public:
using I = IntersectionType;
ElementAndIntersectionFunctor(const std::string& log_prefix = "",
const std::array<bool, 3>& logging_state = {false, false, true})
const std::array<bool, 3>& logging_state = {{false, false, true}})
: Common::WithLogger<ElementAndIntersectionFunctor<GL>>(
log_prefix.empty() ? "ElementAndIntersectionFunctor" : log_prefix, logging_state)
{}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment