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

[python] allow for multiple init_logger() calls

parent e2cc5918
No related branches found
No related tags found
No related merge requests found
...@@ -148,6 +148,9 @@ class dependency_missing : public Dune::Exception ...@@ -148,6 +148,9 @@ class dependency_missing : public Dune::Exception
class this_should_not_happen : public Dune::InvalidStateException class this_should_not_happen : public Dune::InvalidStateException
{}; {};
class logger_error : public Dune::Exception
{};
} // namespace Exceptions } // namespace Exceptions
......
...@@ -47,8 +47,11 @@ void add_initialization(pybind11::module& m, std::string logger_name) ...@@ -47,8 +47,11 @@ void add_initialization(pybind11::module& m, std::string logger_name)
const std::string& info_color, const std::string& info_color,
const std::string& debug_color, const std::string& debug_color,
const std::string& warning_color) { const std::string& warning_color) {
try {
Dune::XT::Common::TimedLogger().create( Dune::XT::Common::TimedLogger().create(
max_info_level, max_debug_level, enable_warnings, enable_colors, info_color, debug_color, warning_color); max_info_level, max_debug_level, enable_warnings, enable_colors, info_color, debug_color, warning_color);
} catch (Dune::XT::Common::Exceptions::logger_error&) {
}
}, },
"max_info_level"_a = std::numeric_limits<ssize_t>::max(), "max_info_level"_a = std::numeric_limits<ssize_t>::max(),
"max_debug_level"_a = std::numeric_limits<ssize_t>::max(), "max_debug_level"_a = std::numeric_limits<ssize_t>::max(),
......
...@@ -95,8 +95,7 @@ void TimedLogging::create(const ssize_t max_info_level, ...@@ -95,8 +95,7 @@ void TimedLogging::create(const ssize_t max_info_level,
const std::string warning_color) const std::string warning_color)
{ {
DUNE_UNUSED std::lock_guard<std::mutex> guard(mutex_); DUNE_UNUSED std::lock_guard<std::mutex> guard(mutex_);
if (created_) DUNE_THROW_IF(created_, Exceptions::logger_error, "Do not call create() more than once!");
DUNE_THROW(Exceptions::you_are_using_this_wrong, "Do not call create() more than once!");
max_info_level_ = max_info_level; max_info_level_ = max_info_level;
max_debug_level_ = max_debug_level; max_debug_level_ = max_debug_level;
enable_warnings_ = enable_warnings; enable_warnings_ = enable_warnings;
......
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