libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
BaseLib::Output Class Reference

Class to print output of different kinds to the standard and error output. More...

#include <Output.h>

Public Member Functions

 Output ()
 The main constructor. More...
 
virtual ~Output ()
 The destructor. More...
 
void init (SharedObjects *baseLib)
 Initializes the object. More...
 
std::string getPrefix ()
 Returns the prefix previously defined with setPrefix. More...
 
void setPrefix (const std::string &prefix)
 Sets a string, which will be used to prefix all output. More...
 
void enableStdOutput ()
 Enables standard output and standard error. More...
 
void disableStdOutput ()
 Disables standard output and standard error. More...
 
void setOutputCallback (std::function< void(int32_t, const std::string &)> value)
 Sets a callback function which will be called for all messages. More...
 
void printEx (const std::string &file, uint32_t line, const std::string &function, const std::string &what="")
 Prints an error message with filename, line number and function name. More...
 
void printCritical (const std::string &message)
 Prints a critical error message (debug level < 1). More...
 
void printError (const std::string &message)
 Prints an error message (debug level < 2). More...
 
void printWarning (const std::string &message)
 Prints a warning message (debug level < 3). More...
 
void printInfo (const std::string &message)
 Prints a info message (debug level < 4). More...
 
void printDebug (const std::string &message, int32_t minDebugLevel=5)
 Prints a debug message (debug level < 5). More...
 
void printMessage (const std::string &message, int32_t minDebugLevel=0, bool errorLog=false)
 Prints a message regardless of the current debug level. More...
 

Static Public Member Functions

static std::string getTimeString (int64_t time=0)
 Returns a time string like "08/27/14 14:13:53.471". More...
 

Detailed Description

Class to print output of different kinds to the standard and error output.

The output is automatically prefixed with the date and filtered according to the current debug level.

Constructor & Destructor Documentation

§ Output()

BaseLib::Output::Output ( )
default

The main constructor.

The constructor does nothing. You need to call "init" after creating the object.

§ ~Output()

BaseLib::Output::~Output ( )
virtualdefault

The destructor.

It does nothing.

Member Function Documentation

§ disableStdOutput()

void BaseLib::Output::disableStdOutput ( )

Disables standard output and standard error.

§ enableStdOutput()

void BaseLib::Output::enableStdOutput ( )

Enables standard output and standard error.

§ getPrefix()

std::string BaseLib::Output::getPrefix ( )

Returns the prefix previously defined with setPrefix.

See also
setPrefix()
Returns
Returns the prefix previously defined with setPrefix.

§ getTimeString()

std::string BaseLib::Output::getTimeString ( int64_t  time = 0)
static

Returns a time string like "08/27/14 14:13:53.471".

Returns
Returns a time string like "08/27/14 14:13:53.471".

§ init()

void BaseLib::Output::init ( SharedObjects baseLib)

Initializes the object.

Not calling this method might cause segmentation faults as the base library pointer is unset.

Parameters
baseLibA pointer to the common base library object.

§ printCritical()

void BaseLib::Output::printCritical ( const std::string &  message)

Prints a critical error message (debug level < 1).

See also
printError()
printWarning()
printInfo()
printDebug()
printMessage()
Parameters
messageThe error message.

§ printDebug()

void BaseLib::Output::printDebug ( const std::string &  message,
int32_t  minDebugLevel = 5 
)

Prints a debug message (debug level < 5).

See also
printCritical()
printError()
printWarning()
printInfo()
printMessage()
Parameters
messageThe message.
minDebugLevelThe minimal debug level (default 5).

§ printError()

void BaseLib::Output::printError ( const std::string &  message)

Prints an error message (debug level < 2).

See also
printCritical()
printWarning()
printInfo()
printDebug()
printMessage()
Parameters
messageThe error message.

§ printEx()

void BaseLib::Output::printEx ( const std::string &  file,
uint32_t  line,
const std::string &  function,
const std::string &  what = "" 
)

Prints an error message with filename, line number and function name.

Parameters
fileThe name of the file where the error occured.
lineThe line number where the error occured.
functionThe function name where the error occured.
whatThe error message.

§ printInfo()

void BaseLib::Output::printInfo ( const std::string &  message)

Prints a info message (debug level < 4).

See also
printCritical()
printError()
printWarning()
printDebug()
printMessage()
Parameters
messageThe message.

§ printMessage()

void BaseLib::Output::printMessage ( const std::string &  message,
int32_t  minDebugLevel = 0,
bool  errorLog = false 
)

Prints a message regardless of the current debug level.

See also
printCritical()
printError()
printWarning()
printInfo()
printDebug()
Parameters
messageThe message.
minDebugLevelThe minimal debug level (default 0).
errorLogIf set to true and minDebugLevel is at least "warning", the message is written to the error log, too (default false).

§ printWarning()

void BaseLib::Output::printWarning ( const std::string &  message)

Prints a warning message (debug level < 3).

See also
printCritical()
printError()
printInfo()
printDebug()
printMessage()
Parameters
messageThe warning message.

§ setOutputCallback()

void BaseLib::Output::setOutputCallback ( std::function< void(int32_t, const std::string &)>  value)

Sets a callback function which will be called for all messages.

First parameter of the function is the debug level (1 = critical, 2 = error, 3 = warning, 4 = info, >= 5 = debug ), second parameter is the message string.

§ setPrefix()

void BaseLib::Output::setPrefix ( const std::string &  prefix)

Sets a string, which will be used to prefix all output.

See also
getPrefix()
Parameters
prefixThe new prefix.

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