-
Notifications
You must be signed in to change notification settings - Fork 5
/
Log.cpp
55 lines (42 loc) · 1.01 KB
/
Log.cpp
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
#include "Log.hpp"
#include <iostream>
#ifdef ___INANITY_PLATFORM_WINDOWS
#include "platform/windows.hpp"
#endif
BEGIN_INANITY
//*** class Log
Log* Log::instance = &StandardLog::cerrInstance;
void Log::SetInstance(Log* log)
{
Log::instance = log;
}
void Log::Message(const String& string)
{
instance->Write(severityMessage, string);
}
void Log::Warning(const String& string)
{
instance->Write(severityWarning, string);
}
void Log::Error(const String& string)
{
instance->Write(severityError, string);
}
//*** class StandardLog
StandardLog StandardLog::cerrInstance(std::cerr);
StandardLog::StandardLog(std::ostream& stream)
: stream(stream) {}
void StandardLog::Write(Severity severity, const String& string)
{
static const char* severities[] =
{
"[MSG ] ", "[WARN] ", "[ERR ] "
};
#if defined(_DEBUG) && defined(___INANITY_PLATFORM_WINDOWS)
if(IsDebuggerPresent())
OutputDebugStringA((severities[severity] + string + "\n").c_str());
else
#endif
stream << severities[severity] << string << '\n';
}
END_INANITY