EMsnap commented on code in PR #9325:
URL: https://github.com/apache/inlong/pull/9325#discussion_r1403001210


##########
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/src/utils/logger.h:
##########
@@ -22,21 +22,42 @@
 #define INLONG_SDK_LOGGER_H
 
 #include "sdk_conf.h"
+#include <iostream>
 #include <log4cplus/fileappender.h>
 #include <log4cplus/helpers/loglog.h>
 #include <log4cplus/initializer.h>
 #include <log4cplus/log4cplus.h>
 #include <log4cplus/logger.h>
 #include <log4cplus/loglevel.h>
+#include <sys/stat.h>
 using namespace log4cplus::helpers;
 
 namespace inlong {
+static const char kDefaultPath[] = "./";
+static const char kLogName[] = "/inlong-sdk.log";
+static bool CheckPath(const std::string &path) {
+  struct stat st_stat = {0};
+  int ret = stat(path.c_str(), &st_stat);
+  if (ret && errno != ENOENT) {
+    std::cout << "Check directory error:" << strerror(errno) << std::endl;
+    return false;
+  }
+
+  if ((ret && errno == ENOENT) || (!ret && !S_ISDIR(st_stat.st_mode))) {
+    if (mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
+      std::cout << "Crate directory error:" << strerror(errno) << std::endl;
+      return false;
+    }
+  }
+  return true;
+}
+
 static void initLog4cplus() {
   std::string log_path = SdkConfig::getInstance()->log_path_;
-  if (log_path.back() != '/') {
-    log_path = "./inlong-sdk-logs/";
+  if (!CheckPath(log_path)) {

Review Comment:
   method naming style is not consistent



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@inlong.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to