Instrument Neutral Distributed Interface INDI  1.9.2
Classes | Namespaces | Macros | Functions
indilogger.h File Reference
#include "indiapi.h"
#include "defaultdevice.h"
#include <stdarg.h>
#include <fstream>
#include <ostream>
#include <string>
#include <sstream>
#include <sys/time.h>

Go to the source code of this file.

Classes

class  INDI::Logger
 The Logger class is a simple logger to log messages to file and INDI clients. This is the implementation of a simple logger in C++. It is implemented as a Singleton, so it can be easily called through two DEBUG macros. It is Pthread-safe. It allows to log on both file and screen, and to specify a verbosity threshold for both of them. More...
 
struct  INDI::Logger::switchinit
 

Namespaces

 INDI
 Namespace to encapsulate INDI client, drivers, and mediator classes.
 

Macros

#define DEBUG_CONF(outputFile, configuration, fileVerbosityLevel, screenVerbosityLevel)
 Macro to configure the logger. Example of configuration of the Logger: DEBUG_CONF("outputfile", Logger::file_on|Logger::screen_on, DBG_DEBUG, DBG_ERROR);. More...
 
#define DEBUG(priority, msg)   INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg)
 Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");. More...
 
#define DEBUGF(priority, msg, ...)   INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg, __VA_ARGS__)
 
#define DEBUGDEVICE(device, priority, msg)   INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg)
 
#define DEBUGFDEVICE(device, priority, msg, ...)   INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg, __VA_ARGS__)
 
#define LOG_ERROR(txt)   DEBUG(INDI::Logger::DBG_ERROR, (txt))
 Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must be defined in the calling scope. More...
 
#define LOG_WARN(txt)   DEBUG(INDI::Logger::DBG_WARNING, (txt))
 
#define LOG_INFO(txt)   DEBUG(INDI::Logger::DBG_SESSION, (txt))
 
#define LOG_DEBUG(txt)   DEBUG(INDI::Logger::DBG_DEBUG, (txt))
 
#define LOG_EXTRA1(txt)   DEBUG(INDI::Logger::DBG_EXTRA_1, (txt))
 
#define LOG_EXTRA2(txt)   DEBUG(INDI::Logger::DBG_EXTRA_2, (txt))
 
#define LOG_EXTRA3(txt)   DEBUG(INDI::Logger::DBG_EXTRA_3, (txt))
 
#define LOGF_ERROR(fmt, ...)   DEBUGF(INDI::Logger::DBG_ERROR, (fmt), __VA_ARGS__)
 
#define LOGF_WARN(fmt, ...)   DEBUGF(INDI::Logger::DBG_WARNING, (fmt), __VA_ARGS__)
 
#define LOGF_INFO(fmt, ...)   DEBUGF(INDI::Logger::DBG_SESSION, (fmt), __VA_ARGS__)
 
#define LOGF_DEBUG(fmt, ...)   DEBUGF(INDI::Logger::DBG_DEBUG, (fmt), __VA_ARGS__)
 
#define LOGF_EXTRA1(fmt, ...)   DEBUGF(INDI::Logger::DBG_EXTRA_1, (fmt), __VA_ARGS__)
 
#define LOGF_EXTRA2(fmt, ...)   DEBUGF(INDI::Logger::DBG_EXTRA_2, (fmt), __VA_ARGS__)
 
#define LOGF_EXTRA3(fmt, ...)   DEBUGF(INDI::Logger::DBG_EXTRA_3, (fmt), __VA_ARGS__)
 

Functions

Logger::loggerConf INDI::operator| (Logger::loggerConf __a, Logger::loggerConf __b)
 
Logger::loggerConf INDI::operator& (Logger::loggerConf __a, Logger::loggerConf __b)
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG (   priority,
  msg 
)    INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg)

Macro to print log messages. Example of usage of the Logger: DEBUG(DBG_DEBUG, "hello " << "world");.

Definition at line 56 of file indilogger.h.

◆ DEBUG_CONF

#define DEBUG_CONF (   outputFile,
  configuration,
  fileVerbosityLevel,
  screenVerbosityLevel 
)
Value:
{ \
Logger::getInstance().configure(outputFile, configuration, fileVerbosityLevel, screenVerbosityLevel); \
}

Macro to configure the logger. Example of configuration of the Logger: DEBUG_CONF("outputfile", Logger::file_on|Logger::screen_on, DBG_DEBUG, DBG_ERROR);.

Definition at line 38 of file indilogger.h.

◆ DEBUGDEVICE

#define DEBUGDEVICE (   device,
  priority,
  msg 
)    INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg)

Definition at line 60 of file indilogger.h.

◆ DEBUGF

#define DEBUGF (   priority,
  msg,
  ... 
)    INDI::Logger::getInstance().print(getDeviceName(), priority, __FILE__, __LINE__, msg, __VA_ARGS__)
Examples
simplescope.cpp.

Definition at line 57 of file indilogger.h.

◆ DEBUGFDEVICE

#define DEBUGFDEVICE (   device,
  priority,
  msg,
  ... 
)    INDI::Logger::getInstance().print(device, priority, __FILE__, __LINE__, msg, __VA_ARGS__)

Definition at line 61 of file indilogger.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   txt)    DEBUG(INDI::Logger::DBG_DEBUG, (txt))

Definition at line 75 of file indilogger.h.

◆ LOG_ERROR

#define LOG_ERROR (   txt)    DEBUG(INDI::Logger::DBG_ERROR, (txt))

Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must be defined in the calling scope.

Usage examples: LOG_DEBUG("hello " << "world"); LOGF_WARN("hello %s", "world");

Definition at line 72 of file indilogger.h.

◆ LOG_EXTRA1

#define LOG_EXTRA1 (   txt)    DEBUG(INDI::Logger::DBG_EXTRA_1, (txt))

Definition at line 76 of file indilogger.h.

◆ LOG_EXTRA2

#define LOG_EXTRA2 (   txt)    DEBUG(INDI::Logger::DBG_EXTRA_2, (txt))

Definition at line 77 of file indilogger.h.

◆ LOG_EXTRA3

#define LOG_EXTRA3 (   txt)    DEBUG(INDI::Logger::DBG_EXTRA_3, (txt))

Definition at line 78 of file indilogger.h.

◆ LOG_INFO

#define LOG_INFO (   txt)    DEBUG(INDI::Logger::DBG_SESSION, (txt))
Examples
simplescope.cpp.

Definition at line 74 of file indilogger.h.

◆ LOG_WARN

#define LOG_WARN (   txt)    DEBUG(INDI::Logger::DBG_WARNING, (txt))

Definition at line 73 of file indilogger.h.

◆ LOGF_DEBUG

#define LOGF_DEBUG (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_DEBUG, (fmt), __VA_ARGS__)

Definition at line 83 of file indilogger.h.

◆ LOGF_ERROR

#define LOGF_ERROR (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_ERROR, (fmt), __VA_ARGS__)

Definition at line 80 of file indilogger.h.

◆ LOGF_EXTRA1

#define LOGF_EXTRA1 (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_EXTRA_1, (fmt), __VA_ARGS__)

Definition at line 84 of file indilogger.h.

◆ LOGF_EXTRA2

#define LOGF_EXTRA2 (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_EXTRA_2, (fmt), __VA_ARGS__)

Definition at line 85 of file indilogger.h.

◆ LOGF_EXTRA3

#define LOGF_EXTRA3 (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_EXTRA_3, (fmt), __VA_ARGS__)

Definition at line 86 of file indilogger.h.

◆ LOGF_INFO

#define LOGF_INFO (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_SESSION, (fmt), __VA_ARGS__)
Examples
simplescope.cpp.

Definition at line 82 of file indilogger.h.

◆ LOGF_WARN

#define LOGF_WARN (   fmt,
  ... 
)    DEBUGF(INDI::Logger::DBG_WARNING, (fmt), __VA_ARGS__)

Definition at line 81 of file indilogger.h.