From 5620806802f76cdec5fc6c9901778bc539050484 Mon Sep 17 00:00:00 2001 From: zogodo <742782908@qq.com> Date: Mon, 17 Feb 2020 21:22:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20web=5Flog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TC1/http_server/web_log.h | 6 +++--- TC1/main.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TC1/http_server/web_log.h b/TC1/http_server/web_log.h index 3e6eada..fcb37c1 100644 --- a/TC1/http_server/web_log.h +++ b/TC1/http_server/web_log.h @@ -21,12 +21,12 @@ extern char time_buf[]; void SetLogRecord(LogRecord* lr, char* log); char* GetLogRecord(); -#define web_log(format, ...) \ +#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"format, time_buf, ##__VA_ARGS__); \ + 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); \ #endif // !WEB_LOG_H diff --git a/TC1/main.h b/TC1/main.h index 661a45b..bbe10a6 100644 --- a/TC1/main.h +++ b/TC1/main.h @@ -4,14 +4,14 @@ #include "mico.h" #include "micokit_ext.h" -#define app_log(M, ...) do { custom_log("APP", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define key_log(M, ...) do { custom_log("KEY", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define ota_log(M, ...) do { custom_log("OTA", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define rtc_log(M, ...) do { custom_log("RTC", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define tc1_log(M, ...) do { custom_log("TC1", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define http_log(M, ...) do { custom_log("HTTP", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define mqtt_log(M, ...) do { custom_log("MQTT", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) -#define wifi_log(M, ...) do { custom_log("WIFI", M, ##__VA_ARGS__); web_log(M, ##__VA_ARGS__) } while(0) +#define app_log(M, ...) do { custom_log("APP", M, ##__VA_ARGS__); web_log("APP", M, ##__VA_ARGS__) } while(0) +#define key_log(M, ...) do { custom_log("KEY", M, ##__VA_ARGS__); web_log("KEY", M, ##__VA_ARGS__) } while(0) +#define ota_log(M, ...) do { custom_log("OTA", M, ##__VA_ARGS__); web_log("OTA", M, ##__VA_ARGS__) } while(0) +#define rtc_log(M, ...) do { custom_log("RTC", M, ##__VA_ARGS__); web_log("RTC", M, ##__VA_ARGS__) } while(0) +#define tc1_log(M, ...) do { custom_log("TC1", M, ##__VA_ARGS__); web_log("TC1", M, ##__VA_ARGS__) } while(0) +#define http_log(M, ...) do { custom_log("HTTP", M, ##__VA_ARGS__); web_log("HTTP", M, ##__VA_ARGS__) } while(0) +#define mqtt_log(M, ...) do { custom_log("MQTT", M, ##__VA_ARGS__); web_log("MQTT", M, ##__VA_ARGS__) } while(0) +#define wifi_log(M, ...) do { custom_log("WIFI", M, ##__VA_ARGS__); web_log("WIFI", M, ##__VA_ARGS__) } while(0) #define VERSION "v1.0.15"