mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-14 14:08:19 +08:00
优化web_log写法
This commit is contained in:
@@ -17,17 +17,15 @@ void SetLogRecord(LogRecord* lr, char* log);
|
||||
char* GetLogRecord();
|
||||
void WebLog(const char *M, ...);
|
||||
|
||||
#define TIM_LEN 32
|
||||
extern LogRecord log_record;
|
||||
extern char* LOG_TMP;
|
||||
extern time_t now;
|
||||
extern char time_buf[];
|
||||
extern time_t LOG_NOW;
|
||||
#define web_log(N, M, ...) \
|
||||
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
|
||||
now = time(NULL); \
|
||||
now += 28800; \
|
||||
strftime(time_buf, TIM_LEN, "%Y-%m-%d %H:%M:%S", localtime(&now)); \
|
||||
snprintf(LOG_TMP, LOG_LEN, "[%s][%s %s:%d] "M, time_buf, N, SHORT_FILE, __LINE__, ##__VA_ARGS__); \
|
||||
LOG_NOW = time(NULL) + 28800; \
|
||||
strftime(LOG_TMP, TIME_LEN, "[%Y-%m-%d %H:%M:%S]", localtime(&LOG_NOW)); \
|
||||
LOG_TMP[TIME_LEN - 1] = ' '; \
|
||||
snprintf(LOG_TMP + TIME_LEN, LOG_LEN - TIME_LEN, "["N" %s:%d] "M, SHORT_FILE, __LINE__, ##__VA_ARGS__); \
|
||||
SetLogRecord(&log_record, LOG_TMP); \
|
||||
|
||||
#define web_log0(N, M, ...) WebLog("["N" %s:%d] "M, SHORT_FILE, __LINE__, ##__VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user