Log_level
struct __log_level;
typedef struct __log_level log_level_t;
=======================
struct __log_level {
/* member variables */
char name[LOG_LEVEL_NAME_LEN];
int value;
/* Convenient variables for fast access */
char value_str[INT_STR_LEN];
char self_str[LOG_LEVEL_STR_LEN];
};
=======================
log_level_t* LOG_OFF
static log_level_t* log_level_new(const char* name, int value)
{
int len = 0;
log_level_t* obj = (log_level_t*)malloc(sizeof(log_level_t));
if (!obj) {
return 0;
}
len = strlen(name) + 1;
strcpy(obj->name, name);
obj->value = value;
SNPRINTF(obj->value_str, INT_STR_LEN, "%d", obj->value);
SNPRINTF(obj->self_str, LOG_LEVEL_STR_LEN, "{class=log_level_t,address=%#x,name=%s,value=%d",
obj, obj->name, obj->value);
return obj;
}
=======================
LOG_OFF = log_level_new("OFF", 8);