mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-14 22:18:14 +08:00
new web_log()
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
LogRecord log_record = { 1,{ 0 } };
|
||||
char log_record_str[LOG_NUM*LOG_LEN] = { 0 };
|
||||
char* LOG_TMP;
|
||||
char log[LOG_LEN];
|
||||
time_t now;
|
||||
char time_buf[TIM_LEN];
|
||||
|
||||
@@ -39,3 +40,19 @@ char* GetLogRecord()
|
||||
return log_record_str;
|
||||
}
|
||||
|
||||
void web_log(const char *N, const char *M, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, M);
|
||||
int ret = vsnprintf(log, sizeof(log), M, ap);
|
||||
va_end(ap);
|
||||
puts(msg);
|
||||
|
||||
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] %s", time_buf, N, SHORT_FILE, __LINE__, log);
|
||||
SetLogRecord(&log_record, LOG_TMP);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,9 @@ extern char time_buf[];
|
||||
|
||||
void SetLogRecord(LogRecord* lr, char* log);
|
||||
char* GetLogRecord();
|
||||
void web_log(const char *N, const char *M, ...);
|
||||
|
||||
#define web_log(N, M, ...) \
|
||||
#define web_log0(N, M, ...) \
|
||||
LOG_TMP = (char*)malloc(sizeof(char)*LOG_LEN); \
|
||||
now = time(NULL); \
|
||||
now += 28800; \
|
||||
|
||||
Reference in New Issue
Block a user