Ack.
Regards, Vu
On 4/7/20 4:33 PM, thien.m.huynh wrote:
---
src/log/logd/lgs_filehdl.cc | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/log/logd/lgs_filehdl.cc b/src/log/logd/lgs_filehdl.cc
index 0d7fb2b74..362df4c27 100644
--- a/src/log/logd/lgs_filehdl.cc
+++ b/src/log/logd/lgs_filehdl.cc
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <unistd.h>
#include <string>
+#include <regex>
#include "base/logtrace.h"
#include "base/osaf_time.h"
@@ -964,13 +965,13 @@ static int chr_cnt_b(char *str, char c, int lim) {
/* Filename prefix (no timestamps or extension */
static std::string file_name_find_g;
static int filter_logfile_name(const struct dirent *finfo) {
- int found = 0;
-
- if ((strstr(finfo->d_name, file_name_find_g.c_str()) != nullptr) &&
- (strstr(finfo->d_name, ".log") != nullptr))
- found = 1;
-
- return found;
+ const std::string pattern =
+ "^" + file_name_find_g + "_[0-9]{8}_[0-9]{6}.log$";
+ const std::regex e{pattern};
+ if (std::regex_match(finfo->d_name, e)) {
+ return true;
+ }
+ return false;
}
/**
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel