38 #define DEBUG_CONF(outputFile, configuration, fileVerbosityLevel, screenVerbosityLevel) \
40 Logger::getInstance().configure(outputFile, configuration, fileVerbosityLevel, screenVerbosityLevel); \
56 #define DEBUG(priority, msg) INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg)
57 #define DEBUGF(priority, msg, ...) \
58 INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg, __VA_ARGS__)
60 #define DEBUGDEVICE(device, priority, msg) INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg)
61 #define DEBUGFDEVICE(device, priority, msg, ...) \
62 INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg, __VA_ARGS__)
72 #define LOG_ERROR(txt) DEBUG(INDI::Logger::DBG_ERROR, (txt))
73 #define LOG_WARN(txt) DEBUG(INDI::Logger::DBG_WARNING, (txt))
74 #define LOG_INFO(txt) DEBUG(INDI::Logger::DBG_SESSION, (txt))
75 #define LOG_DEBUG(txt) DEBUG(INDI::Logger::DBG_DEBUG, (txt))
76 #define LOG_EXTRA1(txt) DEBUG(INDI::Logger::DBG_EXTRA_1, (txt))
77 #define LOG_EXTRA2(txt) DEBUG(INDI::Logger::DBG_EXTRA_2, (txt))
78 #define LOG_EXTRA3(txt) DEBUG(INDI::Logger::DBG_EXTRA_3, (txt))
80 #define LOGF_ERROR(fmt, ...) DEBUGF(INDI::Logger::DBG_ERROR, (fmt), __VA_ARGS__)
81 #define LOGF_WARN(fmt, ...) DEBUGF(INDI::Logger::DBG_WARNING, (fmt), __VA_ARGS__)
82 #define LOGF_INFO(fmt, ...) DEBUGF(INDI::Logger::DBG_SESSION, (fmt), __VA_ARGS__)
83 #define LOGF_DEBUG(fmt, ...) DEBUGF(INDI::Logger::DBG_DEBUG, (fmt), __VA_ARGS__)
84 #define LOGF_EXTRA1(fmt, ...) DEBUGF(INDI::Logger::DBG_EXTRA_1, (fmt), __VA_ARGS__)
85 #define LOGF_EXTRA2(fmt, ...) DEBUGF(INDI::Logger::DBG_EXTRA_2, (fmt), __VA_ARGS__)
86 #define LOGF_EXTRA3(fmt, ...) DEBUGF(INDI::Logger::DBG_EXTRA_3, (fmt), __VA_ARGS__)
121 L_noscreen_ = 1 << 2,
125 #ifdef LOGGER_MULTITHREAD
127 static pthread_mutex_t lock_;
130 bool configured_ {
false };
139 static std::string logFile_;
144 static std::string logDir_;
152 static loggerConf_ configuration_;
157 struct timeval initialTime_;
159 static unsigned int fileVerbosityLevel_;
161 static unsigned int screenVerbosityLevel_;
162 static unsigned int rememberscreenlevel_;
181 inline static void lock();
184 inline static void unlock();
231 return configuration_;
251 int addDebugLevel(
const char *debugLevelName,
const char *LoggingLevelName);
253 void print(
const char *devicename,
const unsigned int verbosityLevel,
const std::string &sourceFile,
256 const char *message, ...);
267 void configure(
const std::string &outputFile,
const loggerConf configuration,
const int fileVerbosityLevel,
268 const int screenVerbosityLevel);
273 static bool ISNewSwitch(
const char *dev,
const char *name,
ISState *states,
char *names[],
int n);
283 static unsigned int rank(
unsigned int l);
286 inline Logger::loggerConf
operator|(Logger::loggerConf __a, Logger::loggerConf __b)
291 inline Logger::loggerConf
operator&(Logger::loggerConf __a, Logger::loggerConf __b)
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Constants and Data structure definitions for the interface to the reference INDI C API implementation...
Namespace to encapsulate INDI client, drivers, and mediator classes.
Logger::loggerConf operator&(Logger::loggerConf __a, Logger::loggerConf __b)
Logger::loggerConf operator|(Logger::loggerConf __a, Logger::loggerConf __b)
The Logger class is a simple logger to log messages to file and INDI clients. This is the implementat...
static ISwitch DebugLevelS[nlevels]
static ISwitch LoggingLevelS[nlevels]
static unsigned int customLevel
static unsigned int rank(unsigned int l)
Method used to print message called by the DEBUG() macro.
static const loggerConf screen_on
static struct switchinit DebugLevelSInit[nlevels]
static const loggerConf file_off
static ISwitchVectorProperty DebugLevelSP
static const unsigned int nlevels
static bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
void configure(const std::string &outputFile, const loggerConf configuration, const int fileVerbosityLevel, const int screenVerbosityLevel)
Method to configure the logger. Called by the DEBUG_CONF() macro. To make implementation easier,...
static ISwitchVectorProperty LoggingLevelSP
void print(const char *devicename, const unsigned int verbosityLevel, const std::string &sourceFile, const int codeLine, const char *message,...)
static Logger & getInstance()
Method to get a reference to the object (i.e., Singleton) It is a static method.
static bool initProperties(INDI::DefaultDevice *device)
static bool updateProperties(bool enable)
static bool saveConfigItems(FILE *fp)
static struct switchinit LoggingLevelSInit[nlevels]
static const loggerConf file_on
static ISwitch ConfigurationS[2]
static std::string getLogFile()
int addDebugLevel(const char *debugLevelName, const char *LoggingLevelName)
Adds a new debugging level to the driver.
static char Tags[nlevels][MAXINDINAME]
static const unsigned int defaultlevel
static loggerConf_ getConfiguration()
static const loggerConf screen_off
static unsigned int nDevices
static ISwitchVectorProperty ConfigurationSP
Switch vector property descriptor.