mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
use global logging level without spdlog
This commit is contained in:
parent
6c69df9fe6
commit
66c4c3bf59
@ -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<Logger>(std::make_shared<spdlog::logger>());
|
||||
}
|
||||
|
||||
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*/)
|
||||
{}
|
||||
|
@ -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<spdlog::logger> logger;
|
||||
|
||||
Logger(std::shared_ptr<spdlog::logger> l) : logger(std::move(l)) {}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user