mirror of
https://github.com/amhndu/SimpleNES.git
synced 2024-06-11 08:56:59 -04:00
Convert unique_ptr based singleton to function-local static object
This commit is contained in:
parent
332199720d
commit
2436034af8
|
@ -45,7 +45,6 @@ namespace sn
|
|||
Level m_logLevel;
|
||||
std::ostream* m_logStream;
|
||||
std::ostream* m_cpuTrace;
|
||||
static std::unique_ptr<Log> m_instance;
|
||||
};
|
||||
|
||||
//Courtesy of http://wordaligned.org/articles/cpp-streambufs#toctee-streams
|
||||
|
|
|
@ -2,17 +2,14 @@
|
|||
|
||||
namespace sn
|
||||
{
|
||||
std::unique_ptr<Log> Log::m_instance = nullptr;
|
||||
|
||||
Log::~Log()
|
||||
{
|
||||
}
|
||||
|
||||
Log& Log::get()
|
||||
{
|
||||
if (!m_instance)
|
||||
m_instance.reset(new Log);
|
||||
return *m_instance;
|
||||
static Log instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::ostream& Log::getCpuTraceStream()
|
||||
|
@ -77,4 +74,4 @@ namespace sn
|
|||
m_tbuf(o1.rdbuf(), o2.rdbuf())
|
||||
{}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue