Adjust log priority for debugging 07/319207/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 17 Oct 2024 09:51:54 +0000 (18:51 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 17 Oct 2024 09:59:21 +0000 (18:59 +0900)
The log priority is determined according to the elpased time required as shown
in the following table:
+---------------+----------+
| elpased time  | priority |
+---------------+----------+
| ~ 0.999       | DEBUG    |
| 1.0 ~ 4.999   | INFO     |
| 5.0 ~ 9.999   | WARN     |
| 10.0 ~        | ERROR    |
+---------------+----------+

Change-Id: I33fadf930f9c18e78dd30f5b709c36436bf544bd
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/rpc-port/tracer-internal.cc

index 7fd21e4529e029d6b6e34e56c75a6bc224b4ec9f..852e92ba91f686016c1dc72f88637bcb73c89514 100644 (file)
 
 #include <utility>
 
+namespace {
+
+log_priority GetLogPriority(double elpased_time) {
+  log_priority priority;
+  if (elpased_time >= 1.0f)
+    priority = DLOG_INFO;
+  else if (elpased_time >= 5.0f)
+    priority = DLOG_WARN;
+  else if (elpased_time >= 10.0f)
+    priority = DLOG_ERROR;
+  else
+    priority = DLOG_DEBUG;
+  return priority;
+}
+
+}  // namespace
+
 namespace rpc_port {
 namespace internal {
 
@@ -41,7 +58,7 @@ Tracer::~Tracer() {
     auto end_time = std::chrono::duration_cast<std::chrono::duration<double>>(
                         end.time_since_epoch())
                         .count();
-    dlog_print(DLOG_INFO, "VTRACE",
+    dlog_print(GetLogPriority(elapsed_time.count()), "VTRACE",
                "[%s]:Took:%.3f s:[%.3f~%.3f]:S[%d]:D[%d:%s]", func_.c_str(),
                elapsed_time.count(), start_time, end_time, gettid(), dest_pid_,
                dest_.c_str());