diff --git a/dune/xt/common/timedlogging.cc b/dune/xt/common/timedlogging.cc index ecd989a72138f9c1671c8829c801cc5c8d504a47..1fa57486633300763ab7c84440ef91854868b124 100644 --- a/dune/xt/common/timedlogging.cc +++ b/dune/xt/common/timedlogging.cc @@ -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() diff --git a/dune/xt/common/timedlogging.hh b/dune/xt/common/timedlogging.hh index 230eb8517ff02db397bf04033130fd50f7c3ca0a..e82783bb07bff2afbfb7023249a84d199f1edda8 100644 --- a/dune/xt/common/timedlogging.hh +++ b/dune/xt/common/timedlogging.hh @@ -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; diff --git a/dune/xt/functions/base/combined-grid-functions.hh b/dune/xt/functions/base/combined-grid-functions.hh index 574b020e03444581191867026a97190acb3883a3..eaa4898738cfb0d671d8b2e919d83c9a3fe6fd26 100644 --- a/dune/xt/functions/base/combined-grid-functions.hh +++ b/dune/xt/functions/base/combined-grid-functions.hh @@ -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()), diff --git a/dune/xt/functions/interfaces/function.hh b/dune/xt/functions/interfaces/function.hh index cf6365238b8c92c94825ed4c854d6e7b376aca9c..dc699d40904eee4c94c319b515dd22108eef70bc 100644 --- a/dune/xt/functions/interfaces/function.hh +++ b/dune/xt/functions/interfaces/function.hh @@ -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() + ")"); } /** diff --git a/dune/xt/functions/interfaces/grid-function.hh b/dune/xt/functions/interfaces/grid-function.hh index 5c2df7609d698958843512e05271c01e84f9ae07..d2ae68ca92a8cad9d18b551b850df2132eab1ee7 100644 --- a/dune/xt/functions/interfaces/grid-function.hh +++ b/dune/xt/functions/interfaces/grid-function.hh @@ -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/(...) /// \} diff --git a/dune/xt/grid/boundaryinfo/interfaces.hh b/dune/xt/grid/boundaryinfo/interfaces.hh index 7d79b9253c8b2276edd161939c80732ee4a4bbc0..d3c4ac893b09cda579d31cfa334e1c46c5b9b4b1 100644 --- a/dune/xt/grid/boundaryinfo/interfaces.hh +++ b/dune/xt/grid/boundaryinfo/interfaces.hh @@ -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; diff --git a/dune/xt/grid/boundaryinfo/normalbased.hh b/dune/xt/grid/boundaryinfo/normalbased.hh index 8a1eeb85e46ee593e641107b803490e87b67d668..f8307d5204d46f8eaacd1212f1429698a4909013 100644 --- a/dune/xt/grid/boundaryinfo/normalbased.hh +++ b/dune/xt/grid/boundaryinfo/normalbased.hh @@ -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)) { diff --git a/dune/xt/grid/filters/base.hh b/dune/xt/grid/filters/base.hh index 6993a8e527db8bf6ffc7b85e68d17714ba5ae09b..4209ee31de22dbd4ea55064d4d8d086c4500dae3 100644 --- a/dune/xt/grid/filters/base.hh +++ b/dune/xt/grid/filters/base.hh @@ -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) {} diff --git a/dune/xt/grid/filters/intersection.hh b/dune/xt/grid/filters/intersection.hh index 3d039a9119314483963af22b63cb7ccf82138fb8..4e995d62096544fe80dd070a3b700204c804a157 100644 --- a/dune/xt/grid/filters/intersection.hh +++ b/dune/xt/grid/filters/intersection.hh @@ -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) {} diff --git a/dune/xt/grid/functors/boundary-detector.hh b/dune/xt/grid/functors/boundary-detector.hh index ebdb56c4e09d9a9e414b49b36b7a2e549716ca02..cc7edd8db7d0dd9f603b9babe9f38ed25600a8e5 100644 --- a/dune/xt/grid/functors/boundary-detector.hh +++ b/dune/xt/grid/functors/boundary-detector.hh @@ -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()) diff --git a/dune/xt/grid/functors/interfaces.hh b/dune/xt/grid/functors/interfaces.hh index a4d5eefc6f0562f2289ef0f1e713326559d25019..ef52fa32ab0b9279d7545cd4e689c63443ad0bb6 100644 --- a/dune/xt/grid/functors/interfaces.hh +++ b/dune/xt/grid/functors/interfaces.hh @@ -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) {}