-
Notifications
You must be signed in to change notification settings - Fork 2
/
debug.h
68 lines (56 loc) · 3.56 KB
/
debug.h
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
#pragma once
#include <iostream>
#include <mutex>
#include <sstream>
#include "notify.h"
extern std::mutex __global_console_lock;
std::string __get_thread_name();
void __set_thread_name(std::string thread_name);
#ifdef __ANDROID_API__
#include <android/log.h>
#ifdef DEBUG
#define DBG(__level, ...) \
{ \
std::stringstream ss; \
__global_console_lock.lock(); \
ss << __get_thread_name() << ": " << __VA_ARGS__; \
__android_log_print(ANDROID_LOG_INFO, "vrok", "%s", ss.str().c_str()); \
__global_console_lock.unlock(); \
}
#else
#define DBG(...)
#endif
#define WARN(__level, ...) \
{ \
std::stringstream ss; \
__global_console_lock.lock(); \
ss << __get_thread_name() << ": " << __VA_ARGS__; \
__android_log_print(ANDROID_LOG_INFO, "vrok", "%s", ss.str().c_str()); \
__global_console_lock.unlock(); \
}
#else
// -- debug
#ifdef DEBUG
#define DBG(__level, ...) \
{ \
std::stringstream __sstream; \
__sstream << __VA_ARGS__; \
vrok::Notify::GetInstance()->NotifyDebug(__level, __sstream.str()); \
}
#else
#define DBG(...)
#endif
// -- warn
#define WARN(__level, ...) \
{ \
std::stringstream __sstream; \
__sstream << __VA_ARGS__; \
vrok::Notify::GetInstance()->NotifyWarning(__level, __sstream.str()); \
}
#define INFO(...) \
{ \
std::stringstream __sstream; \
__sstream << __VA_ARGS__; \
vrok::Notify::GetInstance()->NotifyInformation(__sstream.str()); \
}
#endif