diff --git a/libsrc/core/logging.cpp b/libsrc/core/logging.cpp index a39554f8..cedc99c4 100644 --- a/libsrc/core/logging.cpp +++ b/libsrc/core/logging.cpp @@ -15,12 +15,14 @@ namespace ngcore { std::ostream* testout = new std::ostream(nullptr); // NOLINT + level::level_enum Logger::global_level; + void Logger::log(level::level_enum level, std::string && s) { #ifdef NETGEN_USE_SPDLOG logger->log(spdlog::level::level_enum(level), s); #else // NETGEN_USE_SPDLOG - if(level>level::debug) + if(level>=global_level) std::clog << s << '\n'; #endif // NETGEN_USE_SPDLOG } @@ -126,7 +128,11 @@ namespace ngcore return std::make_shared(std::make_shared()); } - void SetLoggingLevel(level::level_enum /*unused*/, const std::string& /*unused*/) {} + void SetLoggingLevel(level::level_enum level, const std::string& /*unused*/) + { + Logger::SetGlobalLoggingLevel(level); + } + void AddFileSink(const std::string& /*unused*/, level::level_enum /*unused*/, const std::string& /*unused*/) {} diff --git a/libsrc/core/logging.hpp b/libsrc/core/logging.hpp index cbbbea99..adfed7ed 100644 --- a/libsrc/core/logging.hpp +++ b/libsrc/core/logging.hpp @@ -49,7 +49,11 @@ namespace ngcore class Logger { + static NGCORE_API level::level_enum global_level; + public: + static void SetGlobalLoggingLevel( level::level_enum level ) { global_level = level; } + std::shared_ptr logger; Logger(std::shared_ptr l) : logger(std::move(l)) {} diff --git a/libsrc/core/taskmanager.cpp b/libsrc/core/taskmanager.cpp index 291ee42e..6b7b9f9a 100644 --- a/libsrc/core/taskmanager.cpp +++ b/libsrc/core/taskmanager.cpp @@ -74,8 +74,7 @@ namespace ngcore task_manager = new TaskManager(); - // TODO: use logger for output - std::cout << "task-based parallelization (C++11 threads) using "<< task_manager->GetNumThreads() << " threads" << std::endl; + GetLogger("TaskManager")->info("task-based parallelization (C++11 threads) using {} threads", task_manager->GetNumThreads()); #ifdef USE_NUMA numa_run_on_node (0);