nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #675: MINIFICPP-1063 - Log directory location should be configurable
Date Wed, 06 Nov 2019 15:16:57 GMT
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_r343151850
 
 

 ##########
 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';
             exit(1);
           }
 #else
         struct stat logDirStat;
         if (stat(directory.c_str(), &logDirStat) != 0 || !S_ISDIR(logDirStat.st_mode))
{
           if (mkdir(directory.c_str(), 0777) == -1) {
+            std::cerr << directory << " cannot be created due to " << strerror(errno)
<< '\n';
             exit(1);
           }
 #endif
         }
-        file_name = directory + "/" + file_name;
-      }
+      file_name = directory + "/" + file_name;
 
 Review comment:
   Please use _get_separator_ from _FileUtils_, this would break logging on Win!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message