oscap debug helpers private header More...
#include "util.h"#include <assert.h>#include <stdlib.h>#include <stddef.h>#include <stdarg.h>Go to the source code of this file.
Defines | |
| #define | OSCAP_DEBUG_FILE "oscap_debug.log" |
| Hardcodede output filename. | |
| #define | OSCAP_DEBUG_FILE_ENV "OSCAP_DEBUG_FILE" |
| Name of the environment variable that can be used to change the default output filename. | |
| #define | OSCAP_DEBUG_LEVEL_ENV "OSCAP_DEBUG_LEVEL" |
| Name of the environment variable that can be used to change the debug level, i.e. | |
| #define | OSCAP_DEBUG_PATHSTRIP_ENV "OSCAP_DEBUG_PSTRIP" |
| Name of the environment variable that can be used to enable striping of __FILE__ paths. | |
| #define | OSCAP_DEBUGOBJ_SEXP 1 |
| #define | _A(x) assert(x) |
| #define | __dlprintf_wrapper(l,...) __oscap_dlprintf (l, __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) |
| #define | debug(l) if ((__debuglog_level = (__debuglog_level == -1 ? atoi (getenv (OSCAP_DEBUG_LEVEL_ENV) == NULL ? "0" : getenv (OSCAP_DEBUG_LEVEL_ENV)) : __debuglog_level)) && __debuglog_level >= (l)) |
| Using this macro you can create a "debug block" with a verbosity level `l'. | |
| #define | oscap_dlprintf(l,...) __dlprintf_wrapper (l, __VA_ARGS__) |
| Convenience macro for calling __oscap_dlprintf. | |
| #define | dO(type, obj) __oscap_debuglog_object(__FILE__, __PRETTY_FUNCTION__, __LINE__, type, obj) |
| #define | dI(...) oscap_dlprintf(DBG_I, __VA_ARGS__) |
| #define | dW(...) oscap_dlprintf(DBG_W, __VA_ARGS__) |
| #define | dE(...) oscap_dlprintf(DBG_E, __VA_ARGS__) |
Enumerations | |
| enum | { DBG_E = 1, DBG_W, DBG_I } |
Functions | |
| void | __oscap_dlprintf (int level, const char *file, const char *fn, size_t line, const char *fmt,...) |
| Version of the oscap_dprintf function with support for debug level. | |
| void | __oscap_debuglog_object (const char *file, const char *fn, size_t line, int objtype, void *obj) |
Variables | |
| int | __debuglog_level |
oscap debug helpers private header
| #define debug | ( | l | ) | if ((__debuglog_level = (__debuglog_level == -1 ? atoi (getenv (OSCAP_DEBUG_LEVEL_ENV) == NULL ? "0" : getenv (OSCAP_DEBUG_LEVEL_ENV)) : __debuglog_level)) && __debuglog_level >= (l)) |
Using this macro you can create a "debug block" with a verbosity level `l'.
Example: The following code inside the debug block will be executed only if the debug level is larger that or equal to 3.
debug(3) { int foo; foo = do_something_only_in_debug_mode(); ... }
| #define OSCAP_DEBUG_FILE "oscap_debug.log" |
Hardcodede output filename.
This is used as the default filename if the variable specified by OSCAP_DEBUG_FILE_ENV isn't defined.
| #define OSCAP_DEBUG_LEVEL_ENV "OSCAP_DEBUG_LEVEL" |
Name of the environment variable that can be used to change the debug level, i.e.
the number and verbosity of the debug messages. XXX: not implemented yet
| #define OSCAP_DEBUG_PATHSTRIP_ENV "OSCAP_DEBUG_PSTRIP" |
Name of the environment variable that can be used to enable striping of __FILE__ paths.
It's numeric value specifies how many path tokens from the end should remain after striping. Value 1 is equal to basename(__FILE__) If this environment variable isn't defined or is set to 0 then no striping is done.
| #define oscap_dlprintf | ( | l, | |||
| ... | ) | __dlprintf_wrapper (l, __VA_ARGS__) |
Convenience macro for calling __oscap_dlprintf.
Only the fmt & it's arguments need to be specified. The __FILE__, __PRETTY_FUNCTION__ and __LINE__ macros are used for the first three arguments.
| void __oscap_dlprintf | ( | int | level, | |
| const char * | file, | |||
| const char * | fn, | |||
| size_t | line, | |||
| const char * | fmt, | |||
| ... | ||||
| ) |
Version of the oscap_dprintf function with support for debug level.
Uses logic similar to the debug() macro described above.
| level | debug level | |
| file | name of the source file | |
| fn | name of the function | |
| line | current line | |
| fmt | printf-line format string | |
| ... | __oscap_dlprintf parameters |
1.6.1