Instrument Neutral Distributed Interface INDI
2.0.0
|
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...
#include <indilogger.h>
Classes | |
struct | switchinit |
Public Types | |
enum | VerbosityLevel { DBG_IGNORE = 0x0 , DBG_ERROR = 0x1 , DBG_WARNING = 0x2 , DBG_SESSION = 0x4 , DBG_DEBUG = 0x8 , DBG_EXTRA_1 = 0x10 , DBG_EXTRA_2 = 0X20 , DBG_EXTRA_3 = 0x40 , DBG_EXTRA_4 = 0x80 } |
typedef loggerConf_ | loggerConf |
Public Member Functions | |
int | addDebugLevel (const char *debugLevelName, const char *LoggingLevelName) |
Adds a new debugging level to the driver. More... | |
void | print (const char *devicename, const unsigned int verbosityLevel, const std::string &sourceFile, const int codeLine, const char *message,...) |
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, the old stream is always closed. Then, in case, it is open again in append mode. More... | |
Static Public Member Functions | |
static std::string | getLogFile () |
static loggerConf_ | getConfiguration () |
static Logger & | getInstance () |
Method to get a reference to the object (i.e., Singleton) It is a static method. More... | |
static bool | saveConfigItems (FILE *fp) |
static bool | ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n) |
static bool | initProperties (INDI::DefaultDevice *device) |
static bool | updateProperties (bool enable) |
static unsigned int | rank (unsigned int l) |
Method used to print message called by the DEBUG() macro. More... | |
Static Public Attributes | |
static const unsigned int | defaultlevel = DBG_ERROR | DBG_WARNING | DBG_SESSION |
static const unsigned int | nlevels = 8 |
static struct switchinit | LoggingLevelSInit [nlevels] |
static ISwitch | LoggingLevelS [nlevels] |
static ISwitchVectorProperty | LoggingLevelSP |
static ISwitch | ConfigurationS [2] |
static ISwitchVectorProperty | ConfigurationSP |
static const loggerConf | file_on = L_nofile_ |
static const loggerConf | file_off = L_file_ |
static const loggerConf | screen_on = L_noscreen_ |
static const loggerConf | screen_off = L_screen_ |
static unsigned int | customLevel = 4 |
static unsigned int | nDevices = 0 |
static struct switchinit | DebugLevelSInit [nlevels] |
static ISwitch | DebugLevelS [nlevels] |
static ISwitchVectorProperty | DebugLevelSP |
static char | Tags [nlevels][MAXINDINAME] |
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.
The default active debug levels are Error, Warning, and Session. Driver Debug can be enabled by the client.
To add a new debug level, call addDebugLevel(). You can add an additional 4 custom debug/logging levels.
Check INDI Tutorial two for an example simple implementation.
Definition at line 37 of file indilogger.cpp.
typedef loggerConf_ INDI::Logger::loggerConf |
Definition at line 217 of file indilogger.h.
Enumerator | |
---|---|
DBG_IGNORE | |
DBG_ERROR | |
DBG_WARNING | |
DBG_SESSION | |
DBG_DEBUG | |
DBG_EXTRA_1 | |
DBG_EXTRA_2 | |
DBG_EXTRA_3 | |
DBG_EXTRA_4 |
Definition at line 189 of file indilogger.h.
int INDI::Logger::addDebugLevel | ( | const char * | debugLevelName, |
const char * | LoggingLevelName | ||
) |
Adds a new debugging level to the driver.
debugLevelName | The descriptive debug level defined to the client. e.g. Scope Status |
LoggingLevelName | the short logging level recorded in the logfile. e.g. SCOPE |
Definition at line 72 of file indilogger.cpp.
void INDI::Logger::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, the old stream is always closed. Then, in case, it is open again in append mode.
outputFile | of the file used for logging |
configuration | (i.e., log on file and on screen on or off) |
fileVerbosityLevel | threshold for file |
screenVerbosityLevel | threshold for screen |
Definition at line 283 of file indilogger.cpp.
|
inlinestatic |
Definition at line 229 of file indilogger.h.
|
static |
Method to get a reference to the object (i.e., Singleton) It is a static method.
Definition at line 339 of file indilogger.cpp.
|
inlinestatic |
Definition at line 225 of file indilogger.h.
|
static |
Definition at line 85 of file indilogger.cpp.
|
static |
Definition at line 145 of file indilogger.cpp.
void INDI::Logger::print | ( | const char * | devicename, |
const unsigned int | verbosityLevel, | ||
const std::string & | sourceFile, | ||
const int | codeLine, | ||
const char * | message, | ||
... | |||
) |
Definition at line 372 of file indilogger.cpp.
|
static |
Method used to print message called by the DEBUG() macro.
i | which debugging to query its rank. The lower the rank, the more priority it is. |
Definition at line 348 of file indilogger.cpp.
|
static |
Definition at line 136 of file indilogger.cpp.
|
static |
Definition at line 113 of file indilogger.cpp.
|
static |
Definition at line 215 of file indilogger.h.
|
static |
Definition at line 216 of file indilogger.h.
|
static |
Definition at line 222 of file indilogger.h.
|
static |
Definition at line 271 of file indilogger.h.
|
static |
Definition at line 267 of file indilogger.h.
|
static |
Definition at line 272 of file indilogger.h.
|
static |
Definition at line 210 of file indilogger.h.
|
static |
Definition at line 219 of file indilogger.h.
|
static |
Definition at line 218 of file indilogger.h.
|
static |
Definition at line 213 of file indilogger.h.
|
static |
Definition at line 211 of file indilogger.h.
|
static |
Definition at line 214 of file indilogger.h.
|
static |
Definition at line 223 of file indilogger.h.
|
static |
Definition at line 211 of file indilogger.h.
|
static |
Definition at line 221 of file indilogger.h.
|
static |
Definition at line 220 of file indilogger.h.
|
static |
Definition at line 276 of file indilogger.h.