Home2L - C/C++ API v1.4-0-g38cc (2024-05-25)
Smart Tools for a Private Home
|
Macros for logging.
Macros | |
#define | DEBUG(LEVEL, MSG) do { if (envDebug >= LEVEL) { LogPara ("DEBUG-" #LEVEL, __FILE__, __LINE__); LogPrintf (MSG); } } while (0) |
Print a debug message. This is only effective if the tool was compiled with WITH_DEBUG == 1 and the configuration parameter 'debug' is set to a value > 0. More... | |
#define | DEBUGF(LEVEL, FMT) do { if (envDebug >= LEVEL) { LogPara ("DEBUG-" #LEVEL, __FILE__, __LINE__); LogPrintf FMT; } } while (0) |
Print a formatted debug message. The argument must contain a parantheses with arguments, which will then be passed to a printf() function variant. For example: DEBUGF(("Current value is %i", my_value)) | |
#define | INFO(MSG) do { LogPara ("INFO", __FILE__, __LINE__); LogPrintf (MSG); } while (0) |
Print a debug message to the console. | |
#define | INFOF(FMT) do { LogPara ("INFO", __FILE__, __LINE__); LogPrintf FMT; } while (0) |
Print a formatted info message. | |
#define | WARNING(MSG) do { LogPara ("WARNING", __FILE__, __LINE__); LogPrintf (MSG); } while (0) |
Print a warning message to the console. | |
#define | WARNINGF(FMT) do { LogPara ("WARNING", __FILE__, __LINE__); LogPrintf FMT; } while (0) |
Print a formatted warning message. | |
#define | SECURITY(MSG) do { LogPara ("SECURITY", __FILE__, __LINE__); LogPrintf (MSG); } while (0) |
Print a security-related warning to the console. These are warnings an adminstrator should regularly check out for, since they may be caused by an attack. | |
#define | SECURITYF(FMT) do { LogPara ("SECURITY", __FILE__, __LINE__); LogPrintf FMT; } while (0) |
Print a formatted security-related warning. | |
#define | ERROR(MSG) do { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf (MSG); _exit (3); } while (0) |
Print an error message to the console and quit the application. | |
#define | ERRORF(FMT) do { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf FMT; _exit (3); } while (0) |
Print a formatted error message to the console and quit the application. | |
#define | ABORT(MSG) do { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf (MSG); abort (); } while (0) |
Print an error message to the console and abort the application. Unlike ERROR , this uses the abort() system call, which may generate a core dump to be used for debugging. | |
#define | ABORTF(FMT) do { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf FMT; abort (); } while (0) |
Print a formatted error message to the console and abort the application. | |
#define | ASSERT(COND) do { if (!(COND)) { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf ("Assertion failed"); LogStack (); abort (); } } while (0) |
Check a condition and abort the application if not true. | |
#define | ASSERTM(COND, MSG) do { if (!(COND)) { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf ("Assertion failed: %s", MSG); LogStack (); abort (); } } while (0) |
Check a condition and, if not true, abort the application with a message. | |
#define | ASSERTF(COND, FMT) do { if (!(COND)) { LogPara ("ERROR", __FILE__, __LINE__); LogPrintf ("Assertion failed - explanation follows."); LogPrintf FMT; abort (); LogStack (); abort (); } } while (0) |
Check a condition and, if not true, abort the application with a message. | |
#define | ASSERT_WARN(COND) do { if (!(COND)) WARNING("Weak assertion failed"); } while (0) |
Check a condition and emit a warning if not true. | |
Functions | |
void | LogToSyslog (const char *instanceName=NULL) |
Redirect logging to syslog from now; instance name must be passed if this is called before EnvInit() | |
void | LogStack () |
Log a stack trace (requires linker flag '-rdynamic' to print function names) | |
Variables | |
int | envDebug |
Debug level (read-only; may also be mapped to a constant macro). | |
#define DEBUG | ( | LEVEL, | |
MSG | |||
) | do { if (envDebug >= LEVEL) { LogPara ("DEBUG-" #LEVEL, __FILE__, __LINE__); LogPrintf (MSG); } } while (0) |
Print a debug message. This is only effective if the tool was compiled with WITH_DEBUG == 1 and the configuration parameter 'debug' is set to a value > 0.
Conventions for the debug level (examples):
Messages of level 3 or more must have a topic-related prefix "[<topic>]" to allow later filtering,