【修复】关键词过滤功能可能过滤脏数据的情况。

Signed-off-by: armink <armink.ztl@gmail.com>
pull/32/head
armink 7 years ago
parent 5365940bd7
commit 2dfba8ee3a

@ -50,7 +50,7 @@ extern "C" {
#define ELOG_LVL_TOTAL_NUM 6 #define ELOG_LVL_TOTAL_NUM 6
/* EasyLogger software version number */ /* EasyLogger software version number */
#define ELOG_SW_VERSION "2.0.1" #define ELOG_SW_VERSION "2.0.2"
/* EasyLogger assert for developer. */ /* EasyLogger assert for developer. */
#ifdef ELOG_ASSERT_ENABLE #ifdef ELOG_ASSERT_ENABLE

@ -1,7 +1,7 @@
/* /*
* This file is part of the EasyLogger Library. * This file is part of the EasyLogger Library.
* *
* Copyright (c) 2015-2017, Armink, <armink.ztl@gmail.com> * Copyright (c) 2015-2016, Armink, <armink.ztl@gmail.com>
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -497,11 +497,19 @@ void elog_output(uint8_t level, const char *tag, const char *file, const char *f
#endif #endif
/* keyword filter */ /* keyword filter */
if (!strstr(log_buf, elog.filter.keyword)) { if (elog.filter.keyword[0] != '\0') {
//TODO 可以考虑采用KMP及朴素模式匹配字符串提升性能 /* add string end sign */
/* unlock output */ if (fmt_result > -1)
elog_output_unlock(); {
return; log_buf[log_len + fmt_result] = '\0';
}
if (!strstr(log_buf, elog.filter.keyword))
{
/* unlock output */
elog_output_unlock();
return;
}
} }
/* package newline sign */ /* package newline sign */
if ((fmt_result > -1) && (fmt_result + log_len + newline_len <= ELOG_LINE_BUF_SIZE)) { if ((fmt_result > -1) && (fmt_result + log_len + newline_len <= ELOG_LINE_BUF_SIZE)) {

Loading…
Cancel
Save