Immersitech Logo Developer Home
 
Loading...
Searching...
No Matches
immersitech_logger.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef IMM_LOGGER_H_
4#define IMM_LOGGER_H_
5
6#if HAVE_VISIBILITY
7#define IMMERSITECH_LOGGER_API __attribute__((__visibility__("default")))
8#elif defined _WIN32
9#define IMMERSITECH_LOGGER_API __declspec(dllexport)
10#else
11#define IMMERSITECH_LOGGER_API
12#endif
13
14#ifdef __ANDROID__
15#include <android/log.h>
16#define LOG_TAG "immersitech"
17#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
18#endif
19
20#include <string>
21#include <mutex>
22
26typedef enum {
33
38public:
42
46
52 virtual void handle(imm_log_level level, const char* str);
53};
54
60 static imm_logger* m_pThis;
61public:
62
65 virtual ~imm_logger();
66
70
75
80 virtual void log(imm_log_level level, const char* format, ...);
81
86 static std::string to_string(imm_log_level level);
87
91 void set_enabled(bool enable);
92
97
98private:
101 imm_logger();
102
106 imm_logger_handler* handler;
107
110 std::mutex _log_lock;
111
114 bool _enabled;
115
118 imm_log_level _imm_log_level;
119};
120
121#ifndef IMM_LOGGER
122#define IMM_LOGGER imm_logger::get_logger()
123#endif
124
125#endif //IMM_LOGGER_H_
Default Immersitech logger handler.
Definition: immersitech_logger.h:37
virtual ~imm_logger_handler()
Destroy the immersitech logger handler object.
imm_logger_handler()
Construct a new immersitech logger handler object.
virtual void handle(imm_log_level level, const char *str)
This function will process a message and post it to the appropriate log.
Logger class.
Definition: immersitech_logger.h:57
virtual void log(imm_log_level level, const char *format,...)
write a message to a log
static std::string to_string(imm_log_level level)
Convert log level to string.
static imm_logger * get_logger()
Get the logger object.
virtual ~imm_logger()
Destroy the logger object.
void set_enabled(bool enable)
Turn the logger on or off.
void initialize(imm_logger_handler *handler)
Initialize logger with speficied handler.
void set_log_level(imm_log_level level)
Set the log level.
#define IMMERSITECH_LOGGER_API
Definition: immersitech_logger.h:11
imm_log_level
Log level definition.
Definition: immersitech_logger.h:26
@ IMM_LOG_VERBOSE
This level is used for anything, no matter how unimportant.
Definition: immersitech_logger.h:27
@ IMM_LOG_WARNING
This level should be used for something that happened that could lead to an error or unexpected behav...
Definition: immersitech_logger.h:30
@ IMM_LOG_ERROR
This level is exclusively for critical errors that have affected functionality.
Definition: immersitech_logger.h:31
@ IMM_LOG_INFO
This level can be used to print generic information. For example, a participant was added to a room.
Definition: immersitech_logger.h:29
@ IMM_LOG_DEBUG
This level should be used only during a debugging session. It should print information that is helpfu...
Definition: immersitech_logger.h:28