loom
1#include "simodo/inout/log/Logger.h"
2
3#include <mutex>
4
5namespace simodo::inout
6{
7
8std::string Logger::toString(SeverityLevel level)
9{
10std::string res;
11switch(level)
12{
13case SeverityLevel::Debug:
14res = "DEBUG";
15break;
16case SeverityLevel::Info:
17res = "INFO";
18break;
19case SeverityLevel::Warning:
20res = "WARNING";
21break;
22case SeverityLevel::Error:
23res = "ERROR";
24break;
25case SeverityLevel::Critical:
26res = "CRITICAL";
27break;
28}
29return res;
30}
31
32void Logger::output(SeverityLevel level, const std::string & message, const std::string & context)
33{
34if (level >= _min_level) {
35static std::mutex logger_output_mutex;
36std::lock_guard locker(logger_output_mutex);
37_out << toString(level) << ':' << _logger_name << ": " << message << std::endl;
38if (!context.empty())
39_out << context << std::endl;
40}
41}
42
43}
44