防止重复引用

This commit is contained in:
zogodo
2019-12-11 11:15:02 +08:00
parent 3f23c8af1c
commit 7bca1e0a61

View File

@@ -1,6 +1,9 @@
#ifndef WEB_LOG_H
#define WEB_LOG_H
#define LOG_NUM 100 #define LOG_NUM 100
#define LOG_LEN 128 #define LOG_LEN 128
typedef struct typedef struct
{ {
int idx; int idx;
@@ -13,9 +16,9 @@ extern char* LOG_TMP;
void SetLogRecord(LogRecord* lr, char* log); void SetLogRecord(LogRecord* lr, char* log);
char* GetLogRecord(int idx); char* GetLogRecord(int idx);
#define web_log(format, ...) \ #define web_log(format, ...) \
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \ LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
snprintf(LOG_TMP, LOG_LEN, format, ##__VA_ARGS__); \ snprintf(LOG_TMP, LOG_LEN, format, ##__VA_ARGS__); \
SetLogRecord(&log_record, LOG_TMP); \ SetLogRecord(&log_record, LOG_TMP); \
#endif // !WEB_LOG_H