优化 web_log

This commit is contained in:
zogodo
2020-02-17 21:22:08 +08:00
parent 051a9504ee
commit 5620806802
2 changed files with 11 additions and 11 deletions

View File

@@ -21,12 +21,12 @@ extern char time_buf[];
void SetLogRecord(LogRecord* lr, char* log); void SetLogRecord(LogRecord* lr, char* log);
char* GetLogRecord(); char* GetLogRecord();
#define web_log(format, ...) \ #define web_log(N, M, ...) \
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \ LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
now = time(NULL); \ now = time(NULL); \
now += 28800; \ now += 28800; \
strftime(time_buf, TIM_LEN, "[%Y-%m-%d %H:%M:%S]", localtime(&now)); \ strftime(time_buf, TIM_LEN, "%Y-%m-%d %H:%M:%S", localtime(&now)); \
snprintf(LOG_TMP, LOG_LEN, "%s"format, time_buf, ##__VA_ARGS__); \ snprintf(LOG_TMP, LOG_LEN, "[%s][%s %s:%d] "M, time_buf, N, SHORT_FILE, __LINE__, ##__VA_ARGS__); \
SetLogRecord(&log_record, LOG_TMP); \ SetLogRecord(&log_record, LOG_TMP); \
#endif // !WEB_LOG_H #endif // !WEB_LOG_H

View File

@@ -4,14 +4,14 @@
#include "mico.h" #include "mico.h"
#include "micokit_ext.h" #include "micokit_ext.h"
#define app_log(M, ...) do { custom_log("APP", 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(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(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(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(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(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(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(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" #define VERSION "v1.0.15"