From 66bd1bca0dad63bd4667d9944d1b8481f23a4a42 Mon Sep 17 00:00:00 2001 From: zogodo <742782908@qq.com> Date: Wed, 6 Apr 2022 00:52:58 +0800 Subject: [PATCH] use old web_log() --- TC1/http_server/web_log.c | 5 +++++ TC1/http_server/web_log.h | 15 ++++++++++++++- TC1/main.h | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/TC1/http_server/web_log.c b/TC1/http_server/web_log.c index d561b7f..f4c0234 100644 --- a/TC1/http_server/web_log.c +++ b/TC1/http_server/web_log.c @@ -5,6 +5,11 @@ #include"http_server/web_log.h" +char* LOG_TMP; +//char log[LOG_LEN]; +time_t now; +char time_buf[TIM_LEN]; + LogRecord log_record = { 1,{ 0 } }; char log_record_str[LOG_NUM*LOG_LEN] = { 0 }; diff --git a/TC1/http_server/web_log.h b/TC1/http_server/web_log.h index 442d69c..3bb107d 100644 --- a/TC1/http_server/web_log.h +++ b/TC1/http_server/web_log.h @@ -17,6 +17,19 @@ void SetLogRecord(LogRecord* lr, char* log); char* GetLogRecord(); void WebLog(const char *M, ...); -#define web_log(N, M, ...) WebLog("["N" %s:%d] "M, SHORT_FILE, __LINE__, ##__VA_ARGS__) +#define TIM_LEN 32 +extern LogRecord log_record; +extern char* LOG_TMP; +extern time_t now; +extern char time_buf[]; +#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__); \ + SetLogRecord(&log_record, LOG_TMP); \ + +#define web_log0(N, M, ...) WebLog("["N" %s:%d] "M, SHORT_FILE, __LINE__, ##__VA_ARGS__) #endif // !WEB_LOG_H diff --git a/TC1/main.h b/TC1/main.h index eaf15f9..3c4c9df 100644 --- a/TC1/main.h +++ b/TC1/main.h @@ -16,7 +16,7 @@ #define wifi_log(M, ...) do { custom_log("WIFI", M, ##__VA_ARGS__); web_log("WIFI", M, ##__VA_ARGS__); } while(0) #define power_log(M, ...) do { custom_log("POWER", M, ##__VA_ARGS__); web_log("POWER", M, ##__VA_ARGS__); } while(0) -#define VERSION "v2.1.5" +#define VERSION "v2.1.6" #define TYPE 1 #define TYPE_NAME "zTC1"