You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/02/08 04:09:57 UTC

[GitHub] [rocketmq-client-cpp] ifplusor commented on a change in pull request #401: make log dir configurable and make log name compatible with RocketMQ …

ifplusor commented on a change in pull request #401:
URL: https://github.com/apache/rocketmq-client-cpp/pull/401#discussion_r801247795



##########
File path: src/log/Logging.cpp
##########
@@ -99,10 +102,19 @@ elogLevel logAdapter::getLogLevel() {
   return m_logLevel;
 }
 
+void logAdapter::setLogDir() {
+  char* p;
+  if((p = getenv(ROCKETMQ_CLIENT_LOG_DIR.c_str()))) {
+    m_log_dir = p;

Review comment:
       check tailing '/'

##########
File path: src/log/Logging.cpp
##########
@@ -38,16 +38,19 @@ logAdapter* logAdapter::getLogInstance() {
 }
 
 logAdapter::logAdapter() : m_logLevel(eLOG_LEVEL_INFO) {
+  setLogDir();
   string homeDir(UtilAll::getHomeDirectory());
-  homeDir.append("/logs/rocketmq-cpp/");
+  homeDir.append(m_log_dir);
   m_logFile += homeDir;
-  std::string fileName = UtilAll::to_string(getpid()) + "_" + "rocketmq-cpp.log.%N";
+  std::string fileName = "rocketmq_client.log";
   m_logFile += fileName;
 
   // boost::log::expressions::attr<
   // boost::log::attributes::current_thread_id::value_type>("ThreadID");
   boost::log::register_simple_formatter_factory<boost::log::trivial::severity_level, char>("Severity");
-  m_logSink = logging::add_file_log(keywords::file_name = m_logFile, keywords::rotation_size = 100 * 1024 * 1024,
+  m_logSink = logging::add_file_log(keywords::file_name = m_logFile,
+                                    keywords::target_file_name = "rocketmq_client_%Y%m%d-%N.log",
+                                    keywords::rotation_size = 10 * 1024,

Review comment:
       These are breaking changes and should be considered carefully. I suggest splitting these into a separate PR.




-- 
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: dev-unsubscribe@rocketmq.apache.org

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