2018-12-28 17:43:15 +05:00
|
|
|
#include "logging.hpp"
|
|
|
|
|
2019-01-16 18:33:48 +05:00
|
|
|
#include <iostream>
|
|
|
|
|
2018-12-28 17:43:15 +05:00
|
|
|
namespace ngcore
|
|
|
|
{
|
2019-05-28 16:51:53 +05:00
|
|
|
std::ostream* testout = new std::ostream(nullptr); // NOLINT
|
2019-01-16 18:33:48 +05:00
|
|
|
|
2019-10-08 19:51:32 +05:00
|
|
|
level::level_enum Logger::global_level = level::warn;
|
2019-09-09 18:13:08 +05:00
|
|
|
|
2019-01-16 18:33:48 +05:00
|
|
|
void Logger::log(level::level_enum level, std::string && s)
|
|
|
|
{
|
2019-09-09 18:13:08 +05:00
|
|
|
if(level>=global_level)
|
2019-01-16 19:10:53 +05:00
|
|
|
std::clog << s << '\n';
|
2018-12-28 17:43:15 +05:00
|
|
|
}
|
|
|
|
|
2019-01-16 18:33:48 +05:00
|
|
|
} //namespace ngcore
|
|
|
|
|
|
|
|
namespace spdlog
|
|
|
|
{
|
|
|
|
class logger
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
logger() = default;
|
|
|
|
};
|
|
|
|
} // namespace spdlog
|
|
|
|
|
|
|
|
namespace ngcore
|
|
|
|
{
|
2018-12-28 17:43:15 +05:00
|
|
|
|
|
|
|
// Dummy functions if no spdlog is available
|
|
|
|
|
2019-01-16 18:33:48 +05:00
|
|
|
std::shared_ptr<Logger> GetLogger(const std::string& /*unused*/)
|
2018-12-28 17:43:15 +05:00
|
|
|
{
|
2019-01-16 18:33:48 +05:00
|
|
|
return std::make_shared<Logger>(std::make_shared<spdlog::logger>());
|
2018-12-28 17:43:15 +05:00
|
|
|
}
|
2019-01-16 18:33:48 +05:00
|
|
|
|
2019-09-09 18:13:08 +05:00
|
|
|
void SetLoggingLevel(level::level_enum level, const std::string& /*unused*/)
|
|
|
|
{
|
|
|
|
Logger::SetGlobalLoggingLevel(level);
|
|
|
|
}
|
|
|
|
|
2019-01-16 18:33:48 +05:00
|
|
|
void AddFileSink(const std::string& /*unused*/, level::level_enum /*unused*/,
|
|
|
|
const std::string& /*unused*/)
|
2018-12-28 17:43:15 +05:00
|
|
|
{}
|
2019-01-16 18:33:48 +05:00
|
|
|
void AddConsoleSink(level::level_enum /*unused*/, const std::string& /*unused*/) {}
|
2018-12-28 17:43:15 +05:00
|
|
|
void ClearLoggingSinks(const std::string& /*unused*/) {}
|
2019-01-16 18:33:48 +05:00
|
|
|
void FlushOnLoggingLevel(level::level_enum /*unused*/, const std::string& /*unused*/) {}
|
|
|
|
} //namespace ngcore
|