-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflex-Logging.cpp
More file actions
84 lines (65 loc) · 1.78 KB
/
Reflex-Logging.cpp
File metadata and controls
84 lines (65 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "Reflex-Logging.h"
#include <utility>
Reflex::Log::Logger::Logger(const std::string& name)
{
m_loggerName = name;
m_logger = spdlog::get(name);
if (!m_logger)
{
m_logger = spdlog::stdout_color_mt(name);
}
}
Reflex::Log::Logger::Logger(std::shared_ptr<spdlog::logger> pLogger)
{
m_logger = std::move(pLogger);
}
void Reflex::Log::Logger::testLog() const
{
m_logger->info("Log from {1}", m_loggerName);
}
std::string Reflex::Log::Logger::getLoggerName() const {
return m_loggerName;
}
void Reflex::Log::shutdown()
{
spdlog::shutdown();
}
void Reflex::Log::setDefaultLog(const std::string& logName)
{
auto log = spdlog::get(logName);
if (!log)
std::make_shared<Reflex::Log::Logger>("Default-Log");
spdlog::set_default_logger(spdlog::get(logName));
}
void Reflex::Log::removeLog(const std::string& logName)
{
if(spdlog::get(logName))
spdlog::drop(logName);
}
std::shared_ptr<Reflex::Log::Logger> Reflex::Log::createNewLogger(const std::string& logName)
{
using Reflex::Log::Logger;
return std::make_shared<Logger>(logName);
/*if(logMap.empty())
{
auto newLog = std::make_shared<Logger>(logName);
return logMap.try_emplace(logName, newLog).first->second;
}
for(auto t = logMap.begin(); t != logMap.end(); ++t)
{
if(t->first == logName)
{
return t->second;
}
if(t == logMap.end() || logMap.size() == 0)
{
auto newLog = std::make_shared<Logger>(logName);
return logMap.try_emplace(logName, newLog).first->second;
}
}
return nullptr;*/
}
//std::shared_ptr<Reflex::Log::Logger> Reflex::Log::LogRegister::getLoggerByName (const std::string& logName)
//{
// return logMap[logName];
//}