e_log: refactor log format 07/305607/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 5 Feb 2024 08:03:06 +0000 (17:03 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Mon, 5 Feb 2024 09:32:13 +0000 (18:32 +0900)
We reduce the log length as below.
1. remove log level in domain info. (ex. INF<e> -> <e>)
2. print just file name w/o directory and reduce file name length to 18 from 30
3. reduce log tag length to 8 from 10

@log_refactoring

Change-Id: I2f002f89bba05c83a73108a89eb6b4dd558239a9

src/bin/e_log.c
src/include/e_log.h
src/include/e_log_client.h

index 9f081b3..4488090 100644 (file)
@@ -1,15 +1,8 @@
 #include "e_log_intern.h"
+#include <Ecore_File.h>
 
 E_API int e_log_dom = -1;
 
-static const char *_names[] = {
-   "CRI",
-   "ERR",
-   "WRN",
-   "INF",
-   "DBG",
-};
-
 #ifdef HAVE_DLOG
 static Eina_Bool _dlog_enabled = EINA_FALSE;
 #endif
@@ -21,38 +14,28 @@ _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, cons
 #ifdef HAVE_DLOG
    if (_dlog_enabled)
      {
-        int log_level, len = 0;
+        int log_level;
         const char buf[512];
-        char tmp_log_level[512];
-
-        len =  sizeof(tmp_log_level) - 1;
-        tmp_log_level[len] = '\0';
 
         switch (level)
           {
            case EINA_LOG_LEVEL_CRITICAL:
               log_level = DLOG_ERROR;
-              strncpy(tmp_log_level, "FATAL", len);
               break;
            case EINA_LOG_LEVEL_ERR:
               log_level = DLOG_ERROR;
-              strncpy(tmp_log_level, "ERROR", len);
               break;
            case EINA_LOG_LEVEL_WARN:
               log_level = DLOG_WARN;
-              strncpy(tmp_log_level, "WARNING", len);
               break;
            case EINA_LOG_LEVEL_INFO:
               log_level = DLOG_INFO;
-              strncpy(tmp_log_level, "INFO", len);
               break;
            case EINA_LOG_LEVEL_DBG:
               log_level = DLOG_DEBUG;
-              strncpy(tmp_log_level, "DEBUG", len);
               break;
            default:
               log_level = DLOG_VERBOSE;
-              strncpy(tmp_log_level, "VERBOSE", len);
               break;
           }
 
@@ -63,24 +46,21 @@ _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, cons
              if (e_config->log_type == E_LOG_TYPE_SYSTEM)
                {
                   print_system_log(log_level, LOG_TAG,
-                                   "%s<%s> %30.30s:%04d %s",
-                                   _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
-                                   d->domain_str,file, line, buf);
+                                   "<%s> %18.18s:%04d %s",
+                                   d->domain_str, ecore_file_file_get(file), line, buf);
                }
              else
                {
                   dlog_print(log_level, LOG_TAG,
-                             "%s<%s> %30.30s:%04d %s",
-                             _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
-                             d->domain_str,file, line, buf);
+                             "<%s> %18.18s:%04d %s",
+                             d->domain_str, ecore_file_file_get(file), line, buf);
                }
           }
         else
           {
              dlog_print(log_level, LOG_TAG,
-                        "%s<%s> %30.30s:%04d %s",
-                        _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
-                        d->domain_str,file, line, buf);
+                        "<%s> %18.18s:%04d %s",
+                        d->domain_str, ecore_file_file_get(file), line, buf);
           }
         return;
      }
@@ -88,9 +68,8 @@ _e_log_cb(const Eina_Log_Domain *d, Eina_Log_Level level, const char *file, cons
    color = eina_log_level_color_get(level);
 
    fprintf(stdout,
-           "%s%s<" EINA_COLOR_RESET "%s%s>" EINA_COLOR_RESET "%30.30s:%04d" EINA_COLOR_RESET " ",
-           color, _names[level > EINA_LOG_LEVEL_DBG ? EINA_LOG_LEVEL_DBG : level],
-           d->domain_str, color, file, line);
+           "%s<" EINA_COLOR_RESET "%s%s>" EINA_COLOR_RESET "%18.18s:%04d" EINA_COLOR_RESET " ",
+           color, d->domain_str, color, ecore_file_file_get(file), line);
    vfprintf(stdout, fmt, args);
    putc('\n', stdout);
 }
index 2b04954..e278733 100644 (file)
@@ -90,10 +90,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          INF("%10.10s|w:0x%08zx|ec:%8p|",                  \
+          INF("%8.8s|w:0x%08zx|ec:%8p|",                    \
               (t), (e_log_client_util_win_get(ec)), (ec));      \
         else                                                \
-          INF("%10.10s|            |             |",        \
+          INF("%8.8s|            |             |",          \
               (t));                                         \
      }                                                      \
    while (0)
@@ -102,10 +102,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          INF("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          INF("%8.8s|w:0x%08zx|ec:%8p|"f,                  \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          INF("%10.10s|            |             |"f,       \
+          INF("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)
@@ -114,10 +114,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          DBG("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          DBG("%8.8s|w:0x%08zx|ec:%8p|"f,                   \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          DBG("%10.10s|            |             |"f,       \
+          DBG("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)
@@ -126,10 +126,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          ERR("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          ERR("%8.8s|w:0x%08zx|ec:%8p|"f,                   \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          ERR("%10.10s|            |             |"f,       \
+          ERR("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)
index be2f30f..143e8cd 100644 (file)
@@ -20,10 +20,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          INF("%10.10s|w:0x%08zx|ec:%8p|",                  \
+          INF("%8.8s|w:0x%08zx|ec:%8p|",                    \
               (t), (e_log_client_util_win_get(ec)), (ec));      \
         else                                                \
-          INF("%10.10s|            |             |",        \
+          INF("%8.8s|            |             |",          \
               (t));                                         \
      }                                                      \
    while (0)
@@ -32,10 +32,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          INF("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          INF("%8.8s|w:0x%08zx|ec:%8p|"f,                   \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          INF("%10.10s|            |             |"f,       \
+          INF("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)
@@ -44,10 +44,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          DBG("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          DBG("%8.8s|w:0x%08zx|ec:%8p|"f,                   \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          DBG("%10.10s|            |             |"f,       \
+          DBG("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)
@@ -56,10 +56,10 @@ e_log_client_util_win_get(const E_Client *ec)
    do                                                       \
      {                                                      \
         if (ec)                                             \
-          ERR("%10.10s|w:0x%08zx|ec:%8p|"f,                 \
+          ERR("%8.8s|w:0x%08zx|ec:%8p|"f,                   \
               (t), (e_log_client_util_win_get(ec)), (ec), ##x); \
         else                                                \
-          ERR("%10.10s|            |             |"f,       \
+          ERR("%8.8s|            |             |"f,         \
               (t), ##x);                                    \
      }                                                      \
    while (0)