feat:[TS-3718]save slow log file one day one file

This commit is contained in:
wangmm0220 2024-08-02 17:10:21 +08:00
parent 4d19f48d8a
commit f5e35549d7
1 changed files with 9 additions and 9 deletions

View File

@ -182,7 +182,6 @@ int32_t taosInitSlowLog() {
return TAOS_SYSTEM_ERROR(errno);
}
backUpSlowLog();
return 0;
}
@ -403,7 +402,6 @@ static void taosOpenNewSlowLogFile(char* day) {
END:
taosUnLockLogFile(pOldFile);
}
void taosResetLog() {
@ -643,19 +641,19 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
taosMemoryFree(buffer);
}
static void backUpSlowLog(){
static void checkSwitchSlowLogFile(){
char buf[64] = {0};
time_t t = taosTime(NULL);
struct tm tmInfo;
if (taosLocalTime(&t, &tmInfo, buf) != NULL) {
(void)strftime(buf, sizeof(buf), "%Y-%m-%d", &tmInfo);
}
// (void)taosThreadMutexLock(&tsLogObj.logMutex);
// if (strlen(tsLogObj.slowLogDay) == 0) {
// tstrncpy(tsLogObj.slowLogDay, buf, 64);
// }else if (strcmp(tsLogObj.slowLogDay, buf) != 0) {
(void)taosOpenNewSlowLogFile(buf);
// }
(void)taosThreadMutexLock(&tsLogObj.logMutex);
if (strlen(tsLogObj.slowLogDay) == 0) {
tstrncpy(tsLogObj.slowLogDay, buf, 64);
}else if (strcmp(tsLogObj.slowLogDay, buf) != 0) {
taosOpenNewSlowLogFile(buf);
}
(void)taosThreadMutexUnlock(&tsLogObj.logMutex);
}
void taosPrintSlowLog(const char *format, ...) {
@ -683,6 +681,8 @@ void taosPrintSlowLog(const char *format, ...) {
(void)taosWriteFile(tsLogObj.slowHandle->pFile, buffer, len);
}
checkSwitchSlowLogFile();
taosMemoryFree(buffer);
}