This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new af5248e15fc [fix][bug] BE log sys_log_level can't modify to take 
effect dynamically (#30179)
af5248e15fc is described below

commit af5248e15fc1ae184af72422790743a31922e0cb
Author: Guangming Lu <71873108+luguangm...@users.noreply.github.com>
AuthorDate: Sun Jan 21 11:01:55 2024 +0800

    [fix][bug] BE log sys_log_level can't modify to take effect dynamically 
(#30179)
---
 be/src/common/config.cpp    | 10 +++++++++-
 be/src/common/config.h      |  2 ++
 be/src/common/logconfig.cpp | 16 ++++++++++++++++
 be/src/common/logging.h     |  2 ++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp
index 74f24212ef9..b2eb7545611 100644
--- a/be/src/common/config.cpp
+++ b/be/src/common/config.cpp
@@ -200,7 +200,7 @@ DEFINE_Int32(sleep_one_second, "1");
 DEFINE_String(sys_log_dir, "${DORIS_HOME}/log");
 DEFINE_String(user_function_dir, "${DORIS_HOME}/lib/udf");
 // INFO, WARNING, ERROR, FATAL
-DEFINE_String(sys_log_level, "INFO");
+DEFINE_mString(sys_log_level, "INFO");
 // TIME-DAY, TIME-HOUR, SIZE-MB-nnn
 DEFINE_String(sys_log_roll_mode, "SIZE-MB-1024");
 // log roll num
@@ -1485,6 +1485,7 @@ bool init(const char* conf_file, bool fill_conf_map, bool 
must_exist, bool set_t
         if (PERSIST) {                                                         
                   \
             RETURN_IF_ERROR(persist_config(std::string((FIELD).name), VALUE)); 
                   \
         }                                                                      
                   \
+        update_config(std::string((FIELD).name), VALUE);                       
                    \
         return Status::OK();                                                   
                   \
     }
 
@@ -1533,6 +1534,13 @@ Status set_config(const std::string& field, const 
std::string& value, bool need_
                                 it->second.type);
 }
 
+void update_config(const std::string& field, const std::string& value) {
+    if ("sys_log_level" == field) {
+        // update log level
+        update_logging(field, value);
+    }
+}
+
 Status set_fuzzy_config(const std::string& field, const std::string& value) {
     LOG(INFO) << fmt::format("FUZZY MODE: {} has been set to {}", field, 
value);
     return set_config(field, value, false, true);
diff --git a/be/src/common/config.h b/be/src/common/config.h
index 6f4dbada2ae..0b0bccab455 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -1291,5 +1291,7 @@ Status set_fuzzy_config(const std::string& field, const 
std::string& value);
 
 void set_fuzzy_configs();
 
+void update_config(const std::string& field, const std::string& value);
+
 } // namespace config
 } // namespace doris
diff --git a/be/src/common/logconfig.cpp b/be/src/common/logconfig.cpp
index fc81103254a..1c53035317a 100644
--- a/be/src/common/logconfig.cpp
+++ b/be/src/common/logconfig.cpp
@@ -151,4 +151,20 @@ void shutdown_logging() {
     google::ShutdownGoogleLogging();
 }
 
+void update_logging(const std::string& name, const std::string& value) {
+    if ("sys_log_level" == name) {
+        if (iequals(value, "INFO")) {
+            FLAGS_minloglevel = 0;
+        } else if (iequals(value, "WARNING")) {
+            FLAGS_minloglevel = 1;
+        } else if (iequals(value, "ERROR")) {
+            FLAGS_minloglevel = 2;
+        } else if (iequals(value, "FATAL")) {
+            FLAGS_minloglevel = 3;
+        } else {
+            LOG(WARNING) << "update sys_log_level failed, need to be INFO, 
WARNING, ERROR, FATAL";
+        }
+    }
+}
+
 } // namespace doris
diff --git a/be/src/common/logging.h b/be/src/common/logging.h
index 268e803fc29..672edb84e6a 100644
--- a/be/src/common/logging.h
+++ b/be/src/common/logging.h
@@ -72,6 +72,8 @@ bool init_glog(const char* basename);
 // flushed. May only be called once.
 void shutdown_logging();
 
+void update_logging(const std::string& name, const std::string& value);
+
 class TaggableLogger {
 public:
     TaggableLogger(const char* file, int line, google::LogSeverity severity)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to