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

wangdan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new 0dcb32ffa refactor(log): use LOG_FATAL_F instead of LOG_FATAL (#1312)
0dcb32ffa is described below

commit 0dcb32ffaad7a87d88c38f2c18882a2ee567b90a
Author: Yingchun Lai <[email protected]>
AuthorDate: Mon Jan 16 17:06:17 2023 +0800

    refactor(log): use LOG_FATAL_F instead of LOG_FATAL (#1312)
---
 src/http/http_server.cpp                   |  2 +-
 src/runtime/task/simple_task_queue.cpp     |  2 +-
 src/server/pegasus_mutation_duplicator.cpp |  2 +-
 src/shell/commands/duplication.cpp         |  2 +-
 src/test/kill_test/data_verifier.cpp       | 44 +++++++++++++++---------------
 src/test/kill_test/process_kill_testor.cpp |  2 +-
 src/utils/api_utilities.h                  |  1 -
 src/utils/fail_point.cpp                   |  4 +--
 8 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/src/http/http_server.cpp b/src/http/http_server.cpp
index 2de9f1e96..c137d9d3e 100644
--- a/src/http/http_server.cpp
+++ b/src/http/http_server.cpp
@@ -62,7 +62,7 @@ error_s update_config(const http_request &req)
     case http_status_code::internal_server_error:
         return "500 Internal Server Error";
     default:
-        LOG_FATAL("invalid code: %d", code);
+        LOG_FATAL_F("invalid code: {}", static_cast<int>(code));
         __builtin_unreachable();
     }
 }
diff --git a/src/runtime/task/simple_task_queue.cpp 
b/src/runtime/task/simple_task_queue.cpp
index 59376c2dd..a211119ef 100644
--- a/src/runtime/task/simple_task_queue.cpp
+++ b/src/runtime/task/simple_task_queue.cpp
@@ -78,7 +78,7 @@ void simple_timer_service::add_timer(task *task)
         if (!ec) {
             task->enqueue();
         } else if (ec != ::boost::asio::error::operation_aborted) {
-            LOG_FATAL("timer failed for task %s, err = %u", 
task->spec().name.c_str(), ec.value());
+            LOG_FATAL_F("timer failed for task {}, err = {}", 
task->spec().name, ec.message());
         }
 
         // to consume the added ref count by task::enqueue for add_timer
diff --git a/src/server/pegasus_mutation_duplicator.cpp 
b/src/server/pegasus_mutation_duplicator.cpp
index 95728e160..92446b985 100644
--- a/src/server/pegasus_mutation_duplicator.cpp
+++ b/src/server/pegasus_mutation_duplicator.cpp
@@ -65,7 +65,7 @@ using namespace dsn::literals::chrono_literals;
         dsn::from_blob_to_thrift(data, thrift_request);
         return pegasus_hash_key_hash(thrift_request.hash_key);
     }
-    LOG_FATAL("unexpected task code: %s", tc.to_string());
+    LOG_FATAL_F("unexpected task code: {}", tc);
     __builtin_unreachable();
 }
 
diff --git a/src/shell/commands/duplication.cpp 
b/src/shell/commands/duplication.cpp
index 2ec2f9d16..e68fd811e 100644
--- a/src/shell/commands/duplication.cpp
+++ b/src/shell/commands/duplication.cpp
@@ -216,7 +216,7 @@ bool change_dup_status(command_executor *e,
         operation = "removing duplication";
         break;
     default:
-        LOG_FATAL("can't change duplication under status %d", status);
+        LOG_FATAL_F("can't change duplication under status {}", status);
     }
 
     auto err_resp = sc->ddl_client->change_dup_status(app_name, dup_id, 
status);
diff --git a/src/test/kill_test/data_verifier.cpp 
b/src/test/kill_test/data_verifier.cpp
index 6099b0859..07cd835f1 100644
--- a/src/test/kill_test/data_verifier.cpp
+++ b/src/test/kill_test/data_verifier.cpp
@@ -202,30 +202,30 @@ void do_get_range(int thread_id, int round_id, long long 
start_id, long long end
         if (ret == PERR_OK || ret == PERR_NOT_FOUND) {
             long cur_time = get_time();
             if (ret == PERR_NOT_FOUND) {
-                LOG_FATAL("GetThread[%d]: round(%d): get not found: id=%lld, 
try=%d, time=%ld "
-                          "(gpid=%d.%d, server=%s), and exit",
-                          thread_id,
-                          round_id,
-                          id,
-                          try_count,
-                          (cur_time - last_time),
-                          info.app_id,
-                          info.partition_index,
-                          info.server.c_str());
+                LOG_FATAL_F("GetThread[{}]: round({}): get not found: id={}, 
try={}, time={} "
+                            "(gpid={}.{}, server={}), and exit",
+                            thread_id,
+                            round_id,
+                            id,
+                            try_count,
+                            cur_time - last_time,
+                            info.app_id,
+                            info.partition_index,
+                            info.server);
                 exit(-1);
             } else if (value != get_value) {
-                LOG_FATAL("GetThread[%d]: round(%d): get mismatched: id=%lld, 
try=%d, time=%ld, "
-                          "expect_value=%s, real_value=%s (gpid=%d.%d, 
server=%s), and exit",
-                          thread_id,
-                          round_id,
-                          id,
-                          try_count,
-                          (cur_time - last_time),
-                          value.c_str(),
-                          get_value.c_str(),
-                          info.app_id,
-                          info.partition_index,
-                          info.server.c_str());
+                LOG_FATAL_F("GetThread[{}]: round({}): get mismatched: id={}, 
try={}, time={}, "
+                            "expect_value={}, real_value={} (gpid={}.{}, 
server={}), and exit",
+                            thread_id,
+                            round_id,
+                            id,
+                            try_count,
+                            cur_time - last_time,
+                            value,
+                            get_value,
+                            info.app_id,
+                            info.partition_index,
+                            info.server);
                 exit(-1);
             } else {
                 LOG_DEBUG_F("GetThread[{}]: round({}): get succeed: id={}, 
try={}, time={} "
diff --git a/src/test/kill_test/process_kill_testor.cpp 
b/src/test/kill_test/process_kill_testor.cpp
index 11f004e5a..20972969b 100644
--- a/src/test/kill_test/process_kill_testor.cpp
+++ b/src/test/kill_test/process_kill_testor.cpp
@@ -223,7 +223,7 @@ void process_kill_testor::stop_verifier_and_exit(const char 
*msg)
     int ret = dsn::utils::pipe_execute(
         "ps aux | grep pegasus | grep verifier | awk '{print $2}' | xargs kill 
-9", ss);
     CHECK(ret == 0 || ret == 256, "");
-    LOG_FATAL(msg);
+    LOG_FATAL_F(msg);
 }
 
 bool process_kill_testor::check_coredump()
diff --git a/src/utils/api_utilities.h b/src/utils/api_utilities.h
index fc2de636a..e190f990a 100644
--- a/src/utils/api_utilities.h
+++ b/src/utils/api_utilities.h
@@ -89,7 +89,6 @@ extern void dsn_coredump();
 
 #define LOG_WARNING(...) dlog(LOG_LEVEL_WARNING, __VA_ARGS__)
 #define LOG_ERROR(...) dlog(LOG_LEVEL_ERROR, __VA_ARGS__)
-#define LOG_FATAL(...) dlog(LOG_LEVEL_FATAL, __VA_ARGS__)
 
 #define dreturn_not_ok_logged(err, ...)                                        
                    \
     do {                                                                       
                    \
diff --git a/src/utils/fail_point.cpp b/src/utils/fail_point.cpp
index 54c372e45..578214d05 100644
--- a/src/utils/fail_point.cpp
+++ b/src/utils/fail_point.cpp
@@ -62,7 +62,7 @@ inline const char *task_type_to_string(fail_point::task_type 
t)
     case fail_point::Void:
         return "Void";
     default:
-        LOG_FATAL("unexpected type: %d", t);
+        LOG_FATAL_F("unexpected type: {}", t);
         __builtin_unreachable();
     }
 }
@@ -92,7 +92,7 @@ inline const char *task_type_to_string(fail_point::task_type 
t)
 void fail_point::set_action(string_view action)
 {
     if (!parse_from_string(action)) {
-        LOG_FATAL("unrecognized command: %s", action.data());
+        LOG_FATAL_F("unrecognized command: {}", action);
     }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to