Instrument Neutral Distributed Interface INDI  1.2.0
Public Member Functions | Static Public Member Functions | List of all members
INDI::Logger Class Reference

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>

Inherits LoggingLevelSInit, and DebugLevelSInit.

Public Member Functions

int addDebugLevel (const char *debugLevelName, const char *LoggingLevelName)
 Adds a new debugging level to the driver. More...
 
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 LoggergetInstance ()
 Method to get a reference to the object (i.e., Singleton) It is a static method. More...
 
static unsigned int rank (unsigned int l)
 Method used to print message called by the DEBUG() macro. @ param i which debugging to query its rank. The lower the rank, the more priority it is. @ return rank of debugging level requested.
 

Detailed Description

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.

Note
Use DEBUGF macro if you have a variable list message. e.g. DEBUGF(INDI::Logger::DBG_SESSION, "Hello %s!", "There")

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.

Member Function Documentation

int INDI::Logger::addDebugLevel ( const char *  debugLevelName,
const char *  LoggingLevelName 
)

Adds a new debugging level to the driver.

Parameters
debugLevelNameThe descriptive debug level defined to the client. e.g. Scope Status
LoggingLevelNamethe short logging level recorded in the logfile. e.g. SCOPE
Returns
bitmask of the new debugging level to be used for any subsequent calls to DEBUG and DEBUGF to record events to this debug level.
Examples:
simplescope.cpp.

Definition at line 77 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.

Parameters
outputFileof the file used for logging
configuration(i.e., log on file and on screen on or off)
fileVerbosityLevelthreshold for file
screenVerbosityLevelthreshold for screen

Definition at line 292 of file indilogger.cpp.

Logger & INDI::Logger::getInstance ( )
static

Method to get a reference to the object (i.e., Singleton) It is a static method.

Returns
Reference to the object.
Examples:
simplescope.cpp.

Definition at line 344 of file indilogger.cpp.


The documentation for this class was generated from the following files: