-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathlog.cpp
86 lines (65 loc) · 1.5 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
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
85
86
#include "log.h"
Log* Log::_instance = nullptr;
Log::Log()
{ }
Log& Log::Current()
{
if (Log::_instance == nullptr) Log::_instance = new Log();
return *Log::_instance;
}
Log::~Log()
{ }
#ifdef BUILD_ANDROID
#include <android/log.h>
#define APPNAME "PassPerfect"
void Log::Assert(const char* message)
{
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, message, 1);
}
void Log::Debug(const char* message)
{
__android_log_print(ANDROID_LOG_DEBUG, APPNAME, message, 1);
}
void Log::Error(const char* message)
{
__android_log_print(ANDROID_LOG_ERROR, APPNAME, message, 1);
}
void Log::Info(const char* message)
{
__android_log_print(ANDROID_LOG_INFO, APPNAME, message, 1);
}
void Log::Verbose(const char* message)
{
__android_log_print(ANDROID_LOG_VERBOSE, APPNAME, message, 1);
}
void Log::Warn(const char* message)
{
__android_log_print(ANDROID_LOG_WARN, APPNAME, message, 1);
}
#else
#include <iostream>
void Log::Assert(const char* message)
{
std::cout << "ASSERT: " << message << std::endl;
}
void Log::Debug(const char* message)
{
std::cout << "DEBUG: " << message << std::endl;
}
void Log::Error(const char* message)
{
std::cerr << "ERROR: " << message << std::endl;
}
void Log::Info(const char* message)
{
std::cout << "INFO: " << message << std::endl;
}
void Log::Verbose(const char* message)
{
std::cout << "VERBOSE: " << message << std::endl;
}
void Log::Warn(const char* message)
{
std::cout << "WARN: " << message << std::endl;
}
#endif // BUILD_ANDROID