arpadboda commented on a change in pull request #675: MINIFICPP-1063 - Log 
directory location should be configurable
URL: https://github.com/apache/nifi-minifi-cpp/pull/675#discussion_r343151283
 
 

 ##########
 File path: libminifi/src/core/logging/LoggerConfiguration.cpp
 ##########
 @@ -135,31 +135,34 @@ std::shared_ptr<internal::LoggerNamespace> 
LoggerConfiguration::initialize_names
     if ("nullappender" == appender_type || "null appender" == appender_type || 
"null" == appender_type) {
       sink_map[appender_name] = 
std::make_shared<spdlog::sinks::null_sink_st>();
     } else if ("rollingappender" == appender_type || "rolling appender" == 
appender_type || "rolling" == appender_type) {
-      std::string file_name = "";
+      std::string file_name;
       if (!logger_properties->get(appender_key + ".file_name", file_name)) {
         file_name = "minifi-app.log";
       }
-      std::string directory = "";
-      directory = logger_properties->getHome();
-      if (!directory.empty()) {
-        // Create the log directory if needed
-        directory += "/logs";
+      std::string directory;
+      if (!logger_properties->get(appender_key + ".directory", directory)) {
+        // The below part assumes logger_properties->getHome() is existing
+        // Cause minifiHome must be set at MiNiFiMain.cpp?
+        directory = logger_properties->getHome() + "/logs";
+      }
+
 #ifdef WIN32
         struct _stat logDirStat;
         if (_stat(directory.c_str(), &logDirStat) != 0) {
           if (_mkdir(directory.c_str()) == -1) {
+            std::cerr << directory << " cannot be created due to " << 
strerror(errno) << '\n';
 
 Review comment:
   I know that this is already existing code, but as we touch, let's improve it!
   
   The whole ifdef bloat should go away, we can rely on _create_dir_ function 
of _FileUtils_. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to