Immersitech Logo Developer Home
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#include <string>
15#include <mutex>
16
20typedef enum {
27
32public:
36
40
46 virtual void handle(imm_log_level level, const char* str);
47};
48
54 static imm_logger* m_pThis;
55public:
56
59 virtual ~imm_logger();
60
64
69
74 virtual void log(imm_log_level level, const char* format, ...);
75
80 static std::string to_string(imm_log_level level);
81
85 void set_enabled(bool enable);
86
91
92private:
95 imm_logger();
96
100 imm_logger_handler* handler;
101
104 std::mutex _log_lock;
105
108 bool _enabled;
109
112 imm_log_level _imm_log_level;
113};
114
115#ifndef IMM_LOGGER
116#define IMM_LOGGER imm_logger::get_logger()
117#endif
118
119#endif //IMM_LOGGER_H_
Default Immersitech logger handler.
Definition: immersitech_logger.h:31
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:51
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:20
@ IMM_LOG_VERBOSE
This level is used for anything, no matter how unimportant.
Definition: immersitech_logger.h:21
@ 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:24
@ IMM_LOG_ERROR
This level is exclusively for critical errors that have affected functionality.
Definition: immersitech_logger.h:25
@ 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:23
@ IMM_LOG_DEBUG
This level should be used only during a debugging session. It should print information that is helpfu...
Definition: immersitech_logger.h:22