Helper key-value info logging
This commit is contained in:
parent
379bc32985
commit
cd306005bb
|
@ -17,6 +17,8 @@
|
||||||
#define PC_RESET "\x1B[0m"
|
#define PC_RESET "\x1B[0m"
|
||||||
#define PC_BOLD "\e[1m"
|
#define PC_BOLD "\e[1m"
|
||||||
|
|
||||||
|
#define _HBE_KV_LOGLINE_LEFTWIDTH "35"
|
||||||
|
|
||||||
typedef enum hbe_errcode {
|
typedef enum hbe_errcode {
|
||||||
HBE_INTERR_PEEK_OFFSET_GEQ_ZERO = 1,
|
HBE_INTERR_PEEK_OFFSET_GEQ_ZERO = 1,
|
||||||
|
|
||||||
|
@ -51,6 +53,16 @@ void hbe_debug(char *fmt, ...) {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
void hbe_info_kv_boolean(char *name, int state) {
|
||||||
|
const char *color = state ? (PC_BOLD PC_GRN) : PC_MAG;
|
||||||
|
const char *label = state ? "ON" : "OFF";
|
||||||
|
|
||||||
|
hbe_info("%-" _HBE_KV_LOGLINE_LEFTWIDTH "s%s%s" PC_RESET, name, color, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hbe_info_kv_string(char *name, char *value) {
|
||||||
|
hbe_info("%-" _HBE_KV_LOGLINE_LEFTWIDTH "s" PC_BOLD "%s" PC_RESET, name, value);
|
||||||
|
}
|
||||||
|
|
||||||
void hbe_warn(char *fmt, ...) {
|
void hbe_warn(char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
Loading…
Reference in New Issue