Developer Resources
immersitech_logger.h
Go to the documentation of this file.
1
/*
2
#pragma once
3
4
#ifndef IMM_LOGGER_H_
5
#define IMM_LOGGER_H_
6
7
#if HAVE_VISIBILITY
8
#define IMMERSITECH_LOGGER_API __attribute__((__visibility__("default")))
9
#elif defined _WIN32
10
#define IMMERSITECH_LOGGER_API __declspec(dllexport)
11
#else
12
#define IMMERSITECH_LOGGER_API
13
#endif
14
15
#ifdef __ANDROID__
16
#include <android/log.h>
17
#define LOG_TAG "immersitech"
18
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
19
#endif
20
21
#include <string>
22
#include <mutex>
23
27
typedef enum {
28
IMM_LOG_VERBOSE, ///< This level is used for anything, no matter how unimportant
29
IMM_LOG_DEBUG, ///< This level should be used only during a debugging session. It should print information that is helpful to the debugging process
30
IMM_LOG_INFO, ///< This level can be used to print generic information. For example, a participant was added to a room
31
IMM_LOG_WARNING, ///< This level should be used for something that happened that could lead to an error or unexpected behavior
32
IMM_LOG_ERROR ///< This level is exclusively for critical errors that have affected functionality
33
} imm_log_level;
34
38
class IMMERSITECH_LOGGER_API imm_logger_handler {
39
public:
42
imm_logger_handler();
43
46
virtual ~imm_logger_handler();
47
53
virtual void handle(imm_log_level level, const char* str);
54
};
55
58
class IMMERSITECH_LOGGER_API imm_logger {
61
static imm_logger* m_pThis;
62
public:
63
66
virtual ~imm_logger();
67
70
void initialize(imm_logger_handler* handler);
71
75
static imm_logger* get_logger();
76
81
virtual void log(imm_log_level level, const char* format, ...);
82
87
static std::string to_string(imm_log_level level);
88
92
void set_enabled(bool enable);
93
97
void set_log_level(imm_log_level level);
98
99
private:
102
imm_logger();
103
107
imm_logger_handler* handler;
108
111
std::mutex _log_lock;
112
115
bool _enabled;
116
119
imm_log_level _imm_log_level;
120
};
121
122
#ifndef IMM_LOGGER
123
#define IMM_LOGGER imm_logger::get_logger()
124
#endif
125
126
#endif //IMM_LOGGER_H_
127
*/
include
immersitech_logger.h