mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
简化日志
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include "user_power.h"
|
||||
#include "main.h"
|
||||
#include "web_data.c"
|
||||
#include "web_log.h"
|
||||
#include "timed_task/timed_task.h"
|
||||
#include "ota_server/user_ota.h"
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
LogRecord log_record = { 1,{ 0 } };
|
||||
char log_record_str[LOG_NUM*LOG_LEN] = { 0 };
|
||||
char* LOG_TMP;
|
||||
time_t now;
|
||||
char time_buf[TIM_LEN];
|
||||
|
||||
void SetLogRecord(LogRecord* lr, char* log)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
#include <time.h>
|
||||
#include "mico.h"
|
||||
#include "micokit_ext.h"
|
||||
#include "sys/time.h"
|
||||
|
||||
#ifndef WEB_LOG_H
|
||||
#define WEB_LOG_H
|
||||
|
||||
#define LOG_NUM 100
|
||||
#define LOG_LEN 128
|
||||
#define TIM_LEN 32
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -12,13 +18,17 @@ typedef struct
|
||||
|
||||
extern LogRecord log_record;
|
||||
extern char* LOG_TMP;
|
||||
extern time_t now;
|
||||
extern char time_buf[];
|
||||
|
||||
void SetLogRecord(LogRecord* lr, char* log);
|
||||
char* GetLogRecord(int idx);
|
||||
|
||||
#define web_log(format, ...) \
|
||||
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
|
||||
snprintf(LOG_TMP, LOG_LEN, format, ##__VA_ARGS__); \
|
||||
now = 1234567; \
|
||||
strftime(time_buf, TIM_LEN, "[%Y-%m-%d %H:%M:%S]", localtime(&now)); \
|
||||
snprintf(LOG_TMP, LOG_LEN, "%s"format, time_buf, ##__VA_ARGS__); \
|
||||
SetLogRecord(&log_record, LOG_TMP); \
|
||||
|
||||
#endif // !WEB_LOG_H
|
||||
|
||||
Reference in New Issue
Block a user