add tags to logging

This commit is contained in:
Conor Patrick
2018-05-18 11:40:17 -04:00
parent a0f54cf142
commit 6ea2a3bf60
4 changed files with 211 additions and 137 deletions

25
log.h
View File

@@ -4,13 +4,30 @@
#define DEBUG_LEVEL 1
#define ENABLE_FILE_LOGGING
void LOG(const char * tag, int num, const char * fmt, ...);
void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...);
void LOG_HEX(uint32_t tag, uint8_t * data, int length);
void set_logging_mask(uint32_t mask);
typedef enum
{
TAG_MC = (1 << 0),
TAG_GA = (1 << 1),
TAG_CP = (1 << 2),
TAG_ERR = (1 << 3),
TAG_PARSE= (1 << 4),
TAG_CTAP = (1 << 5),
TAG_DUMP = (1 << 6),
TAG_FILENO = (1<<31)
} LOG_TAG;
#if DEBUG_LEVEL == 1
#define printf1 printf
#define printf2(fmt, ...) LOG(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define printf3(fmt, ...) LOG(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define printf1(tag,fmt, ...) LOG(tag & ~(TAG_FILENO), NULL, 0, fmt, ##__VA_ARGS__)
#define printf2(tag,fmt, ...) LOG(tag | TAG_FILENO,__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define printf3(tag,fmt, ...) LOG(tag | TAG_FILENO,__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define dump_hex1(tag,data,len) LOG_HEX(tag,data,len)
#else