Files | |
file | ub_logging.h |
Control logging by levels and categories. | |
Functions | |
void | ub_console_debug_select_print (bool console, bool debug, const char *astr) |
output to console out and debug out by selection More... | |
const char * | ub_log_initstr_override (const char *ns, const char *os) |
override 'istr' of ub_log_inig More... | |
void | ub_log_init (const char *istr) |
initialize logging by a string More... | |
int | ub_log_add_category (const char *catstr) |
add a category of logging at the bottom of the index More... | |
int | ub_log_print (int cat_index, int flags, ub_dbgmsg_level_t level, const char *astr) |
print log message More... | |
bool | ub_clog_on (int cat_index, ub_dbgmsg_level_t level) |
check if console log is enabled or not for the indicated cat_index and level More... | |
bool | ub_dlog_on (int cat_index, ub_dbgmsg_level_t level) |
check if debug log is enabled or not for the indicated cat_index and level More... | |
int | ub_log_change (int cat_index, ub_dbgmsg_level_t clevel, ub_dbgmsg_level_t dlevel) |
change console log level to clevel, and debug log level to delevl More... | |
int | ub_log_return (int cat_index) |
return console log level and console log level to the previous status More... | |
void | ub_log_flush (void) |
flush out messages on the both of cosole log and debug log More... | |
Typedefs | |
typedef int | ub_dbgmsg_level_t |
This defines different logging levels. More... | |
Macros | |
#define | UBL_NONE 0 |
#define | UBL_FATAL 1 |
#define | UBL_ERROR 2 |
#define | UBL_WARN 3 |
#define | UBL_INFO 4 |
#define | UBL_INFOV 5 |
#define | UBL_DEBUG 6 |
#define | UBL_DEBUGV 7 |
#define | MAX_LOGMSG_CATEGORIES 16 |
maximum number of categories More... | |
#define | DBGMSG_LEVEL_MARK {"NON", "FTL", "ERR", "WRN", "INF", "IFV", "DBG", "DBV"} |
3-charcter string to represent each logging level More... | |
#define | UBL_TS_BIT_FIELDS 3 |
lowest 2 bits are used for TS Clock type, use ub_clocktype_t UB_CLOCK_DEFAULT means no-timestamp More... | |
#define | UB_LOG_COMPILE_LEVEL UBL_DEBUGV |
#define | UB_LOG_IS_COMPILED(level) (UB_LOG_COMPILE_LEVEL >= level) |
#define | UB_LOG_HELPER(level, tstype, ...) |
#define | UB_LOG_UBL_DEBUGV(...) UB_LOG_HELPER(UBL_DEBUGV, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_DEBUGV(...) UB_LOG_HELPER(UBL_DEBUGV, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_DEBUG(...) UB_LOG_HELPER(UBL_DEBUG, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_DEBUG(...) UB_LOG_HELPER(UBL_DEBUG, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_INFOV(...) UB_LOG_HELPER(UBL_INFOV, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_INFOV(...) UB_LOG_HELPER(UBL_INFOV, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_INFO(...) UB_LOG_HELPER(UBL_INFO, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_INFO(...) UB_LOG_HELPER(UBL_INFO, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_WARN(...) UB_LOG_HELPER(UBL_WARN, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_WARN(...) UB_LOG_HELPER(UBL_WARN, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_ERROR(...) UB_LOG_HELPER(UBL_ERROR, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_ERROR(...) UB_LOG_HELPER(UBL_ERROR, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_FATAL(...) UB_LOG_HELPER(UBL_FATAL, 0, __VA_ARGS__) |
#define | UB_TLOG_UBL_FATAL(...) UB_LOG_HELPER(UBL_FATAL, UB_LOGTSTYPE, __VA_ARGS__) |
#define | UB_LOG_UBL_NONE(...) |
#define | UB_TLOG_UBL_NONE(...) |
#define | UBL_OVERRIDE_ISTR(x, y) ub_log_initstr_override(x,UBB_GETENV(y)) |
override valuse 'x' to the value of the environment variable 'y' More... | |
#define | PRINT_FORMAT_ATTRIBUTE1 __attribute__((format (printf, 1, 2))) |
let the compiler show warning when printf type format is wrong More... | |
#define | PRINT_FORMAT_ATTRIBUTE4 __attribute__((format (printf, 4, 5))) |
format starts at 4th argument More... | |
#define UBL_NONE 0 |
#define UBL_FATAL 1 |
#define UBL_ERROR 2 |
#define UBL_WARN 3 |
#define UBL_INFO 4 |
#define UBL_INFOV 5 |
#define UBL_DEBUG 6 |
#define UBL_DEBUGV 7 |
#define MAX_LOGMSG_CATEGORIES 16 |
maximum number of categories
#define DBGMSG_LEVEL_MARK {"NON", "FTL", "ERR", "WRN", "INF", "IFV", "DBG", "DBV"} |
3-charcter string to represent each logging level
#define UBL_TS_BIT_FIELDS 3 |
lowest 2 bits are used for TS Clock type, use ub_clocktype_t UB_CLOCK_DEFAULT means no-timestamp
#define UB_LOG_COMPILE_LEVEL UBL_DEBUGV |
#define UB_LOG_IS_COMPILED | ( | level | ) | (UB_LOG_COMPILE_LEVEL >= level) |
#define UB_LOG_HELPER | ( | level, | |
tstype, | |||
... | |||
) |
#define UB_LOG_UBL_DEBUGV | ( | ... | ) | UB_LOG_HELPER(UBL_DEBUGV, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_DEBUGV | ( | ... | ) | UB_LOG_HELPER(UBL_DEBUGV, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_DEBUG | ( | ... | ) | UB_LOG_HELPER(UBL_DEBUG, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_DEBUG | ( | ... | ) | UB_LOG_HELPER(UBL_DEBUG, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_INFOV | ( | ... | ) | UB_LOG_HELPER(UBL_INFOV, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_INFOV | ( | ... | ) | UB_LOG_HELPER(UBL_INFOV, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_INFO | ( | ... | ) | UB_LOG_HELPER(UBL_INFO, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_INFO | ( | ... | ) | UB_LOG_HELPER(UBL_INFO, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_WARN | ( | ... | ) | UB_LOG_HELPER(UBL_WARN, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_WARN | ( | ... | ) | UB_LOG_HELPER(UBL_WARN, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_ERROR | ( | ... | ) | UB_LOG_HELPER(UBL_ERROR, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_ERROR | ( | ... | ) | UB_LOG_HELPER(UBL_ERROR, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_FATAL | ( | ... | ) | UB_LOG_HELPER(UBL_FATAL, 0, __VA_ARGS__) |
#define UB_TLOG_UBL_FATAL | ( | ... | ) | UB_LOG_HELPER(UBL_FATAL, UB_LOGTSTYPE, __VA_ARGS__) |
#define UB_LOG_UBL_NONE | ( | ... | ) |
#define UB_TLOG_UBL_NONE | ( | ... | ) |
#define UBL_OVERRIDE_ISTR | ( | x, | |
y | |||
) | ub_log_initstr_override(x,UBB_GETENV(y)) |
override valuse 'x' to the value of the environment variable 'y'
#define PRINT_FORMAT_ATTRIBUTE1 __attribute__((format (printf, 1, 2))) |
let the compiler show warning when printf type format is wrong
format starts at 1st argument
#define PRINT_FORMAT_ATTRIBUTE4 __attribute__((format (printf, 4, 5))) |
format starts at 4th argument
typedef int ub_dbgmsg_level_t |
This defines different logging levels.
void ub_console_debug_select_print | ( | bool | console, |
bool | debug, | ||
const char * | astr | ||
) |
output to console out and debug out by selection
console | select output to console |
debug | select output to debug memory |
astr | a string to print |
const char* ub_log_initstr_override | ( | const char * | ns, |
const char * | os | ||
) |
override 'istr' of ub_log_inig
ns | original 'istr' |
os | overriding string |
void ub_log_init | ( | const char * | istr | ) |
initialize logging by a string
istr | initialization string |
int ub_log_add_category | ( | const char * | catstr | ) |
add a category of logging at the bottom of the index
catstr | category initialization string |
int ub_log_print | ( | int | cat_index, |
int | flags, | ||
ub_dbgmsg_level_t | level, | ||
const char * | astr | ||
) |
print log message
cat_index | index of categories, the index is defined by the initialization string in unibase_init function |
flags | timestamp option is defined in lower 2 bits. |
level | log level, see ub_dbgmsg_level_t |
astr | a string to print |
bool ub_clog_on | ( | int | cat_index, |
ub_dbgmsg_level_t | level | ||
) |
check if console log is enabled or not for the indicated cat_index and level
bool ub_dlog_on | ( | int | cat_index, |
ub_dbgmsg_level_t | level | ||
) |
check if debug log is enabled or not for the indicated cat_index and level
int ub_log_change | ( | int | cat_index, |
ub_dbgmsg_level_t | clevel, | ||
ub_dbgmsg_level_t | dlevel | ||
) |
change console log level to clevel, and debug log level to delevl
int ub_log_return | ( | int | cat_index | ) |
return console log level and console log level to the previous status
void ub_log_flush | ( | void | ) |
flush out messages on the both of cosole log and debug log