diff --git a/src/HDLog.c b/src/HDLog.c index 4499882..57f221d 100644 --- a/src/HDLog.c +++ b/src/HDLog.c @@ -221,6 +221,11 @@ static uint8_t HDLogFpgaError(const uint8_t *data, int len, uint8_t isWrite, uin } #endif + if (HBitGet(sLogItem, kLogLevelHex) == 0) + { + return 0; + } + const char *opt = isWrite ? "write" : "read"; printf("%s fpga error, len[%d]\r\n", opt, len); HDLogHex((const uint8_t *)(data), len, 1, NULL); @@ -230,13 +235,10 @@ static uint8_t HDLogFpgaError(const uint8_t *data, int len, uint8_t isWrite, uin uint8_t HDLogPrintFpgaHeader(const uint8_t *data, int len, uint8_t isWrite, uint8_t checkFpga) { - if (HBitGet(sLogItem, kLogLevelHex) == 0) - { - return 0; - } + const HBitType isPrint = HBitGet(sLogItem, kLogLevelHex); // 记录打印时间 - if (sGetTime) + if (isPrint && sGetTime) { uint32_t ms = sGetTime(); printf("[%d:%02d:%02d.%03d]\r\n", ms / 1000 / 60 / 60, ms / 1000 / 60 % 60, ms / 1000 % 60, ms % 1000); @@ -294,6 +296,11 @@ uint8_t HDLogPrintFpgaHeader(const uint8_t *data, int len, uint8_t isWrite, uint typeCount = *GetFpgaType(type, isWrite); #endif + if (isPrint == 0) + { + return 1; + } + const char *opt = isWrite ? "write" : "read"; printf("%s[%u], typeCount[%u] - type[%02X], sendCard[%d], netPort[%d], cardNumber[%d], subFunc[%04X], group[%04X], effectLen[%d]\r\n", opt, count, typeCount, type, sendCard, port, recvCardNumber, subFunc, group, effectLen);