libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
|
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... | |
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.
|
default |
The main constructor.
The constructor does nothing. You need to call "init" after creating the object.
|
virtualdefault |
The destructor.
It does nothing.
void BaseLib::Output::disableStdOutput | ( | ) |
Disables standard output and standard error.
void BaseLib::Output::enableStdOutput | ( | ) |
Enables standard output and standard error.
std::string BaseLib::Output::getPrefix | ( | ) |
Returns the prefix previously defined with setPrefix.
|
static |
Returns a time string like "08/27/14 14:13:53.471".
void BaseLib::Output::init | ( | SharedObjects * | baseLib | ) |
Initializes the object.
Not calling this method might cause segmentation faults as the base library pointer is unset.
baseLib | A pointer to the common base library object. |
void BaseLib::Output::printCritical | ( | const std::string & | message | ) |
Prints a critical error message (debug level < 1).
message | The error message. |
void BaseLib::Output::printDebug | ( | const std::string & | message, |
int32_t | minDebugLevel = 5 |
||
) |
Prints a debug message (debug level < 5).
message | The message. |
minDebugLevel | The minimal debug level (default 5). |
void BaseLib::Output::printError | ( | const std::string & | message | ) |
Prints an error message (debug level < 2).
message | The error message. |
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.
file | The name of the file where the error occured. |
line | The line number where the error occured. |
function | The function name where the error occured. |
what | The error message. |
void BaseLib::Output::printInfo | ( | const std::string & | message | ) |
Prints a info message (debug level < 4).
message | The message. |
void BaseLib::Output::printMessage | ( | const std::string & | message, |
int32_t | minDebugLevel = 0 , |
||
bool | errorLog = false |
||
) |
Prints a message regardless of the current debug level.
message | The message. |
minDebugLevel | The minimal debug level (default 0). |
errorLog | If set to true and minDebugLevel is at least "warning", the message is written to the error log, too (default false). |
void BaseLib::Output::printWarning | ( | const std::string & | message | ) |
Prints a warning message (debug level < 3).
message | The warning message. |
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.
void BaseLib::Output::setPrefix | ( | const std::string & | prefix | ) |
Sets a string, which will be used to prefix all output.
prefix | The new prefix. |