There is no need for end users to know the function details.

Signed-off-by: Gao Xiang <[email protected]>
---
 include/erofs/print.h | 73 ++++++++++++++++++++++---------------------
 lib/block_list.c      |  2 +-
 lib/io.c              |  2 +-
 3 files changed, 40 insertions(+), 37 deletions(-)

diff --git a/include/erofs/print.h b/include/erofs/print.h
index 57b6607..91f864b 100644
--- a/include/erofs/print.h
+++ b/include/erofs/print.h
@@ -19,52 +19,55 @@ enum {
        EROFS_MSG_MAX = 9
 };
 
+#ifndef EROFS_MODNAME
+#define EROFS_MODNAME  "erofs"
+#endif
 #define FUNC_LINE_FMT "%s() Line[%d] "
 
+#ifdef NDEBUG
+#ifndef pr_fmt
+#define pr_fmt(fmt)    EROFS_MODNAME ": " fmt "\n"
+#endif
+#define PR_FMT_FUNC_LINE(fmt)  pr_fmt(fmt)
+#else
 #ifndef pr_fmt
-#define pr_fmt(fmt) "EROFS: " FUNC_LINE_FMT fmt "\n"
+#define pr_fmt(fmt)    EROFS_MODNAME ": " FUNC_LINE_FMT fmt "\n"
+#endif
+#define PR_FMT_FUNC_LINE(fmt)  pr_fmt(fmt), __func__, __LINE__
 #endif
 
-#define erofs_dbg(fmt, ...) do {                               \
-       if (cfg.c_dbg_lvl >= EROFS_DBG) {                       \
-               fprintf(stdout,                                 \
-                       pr_fmt(fmt),                            \
-                       __func__,                               \
-                       __LINE__,                               \
-                       ##__VA_ARGS__);                         \
-       }                                                       \
+#define erofs_dbg(fmt, ...) do {                       \
+       if (cfg.c_dbg_lvl >= EROFS_DBG) {               \
+               fprintf(stdout,                         \
+                       "<D> " PR_FMT_FUNC_LINE(fmt),   \
+                       ##__VA_ARGS__);                 \
+       }                                               \
 } while (0)
 
-#define erofs_info(fmt, ...) do {                              \
-       if (cfg.c_dbg_lvl >= EROFS_INFO) {                      \
-               fprintf(stdout,                                 \
-                       pr_fmt(fmt),                            \
-                       __func__,                               \
-                       __LINE__,                               \
-                       ##__VA_ARGS__);                         \
-               fflush(stdout);                                 \
-       }                                                       \
+#define erofs_info(fmt, ...) do {                      \
+       if (cfg.c_dbg_lvl >= EROFS_INFO) {              \
+               fprintf(stdout,                         \
+                       "<I> " PR_FMT_FUNC_LINE(fmt),   \
+                       ##__VA_ARGS__);                 \
+               fflush(stdout);                         \
+       }                                               \
 } while (0)
 
-#define erofs_warn(fmt, ...) do {                              \
-       if (cfg.c_dbg_lvl >= EROFS_WARN) {                      \
-               fprintf(stdout,                                 \
-                       pr_fmt(fmt),                            \
-                       __func__,                               \
-                       __LINE__,                               \
-                       ##__VA_ARGS__);                         \
-               fflush(stdout);                                 \
-       }                                                       \
+#define erofs_warn(fmt, ...) do {                      \
+       if (cfg.c_dbg_lvl >= EROFS_WARN) {              \
+               fprintf(stdout,                         \
+                       "<W> " PR_FMT_FUNC_LINE(fmt),   \
+                       ##__VA_ARGS__);                 \
+               fflush(stdout);                         \
+       }                                               \
 } while (0)
 
-#define erofs_err(fmt, ...) do {                               \
-       if (cfg.c_dbg_lvl >= EROFS_ERR) {                       \
-               fprintf(stderr,                                 \
-                       "Err: " pr_fmt(fmt),                    \
-                       __func__,                               \
-                       __LINE__,                               \
-                       ##__VA_ARGS__);                         \
-       }                                                       \
+#define erofs_err(fmt, ...) do {                       \
+       if (cfg.c_dbg_lvl >= EROFS_ERR) {               \
+               fprintf(stderr,                         \
+                       "<E> " PR_FMT_FUNC_LINE(fmt),   \
+                       ##__VA_ARGS__);                 \
+       }                                               \
 } while (0)
 
 #define erofs_dump(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
diff --git a/lib/block_list.c b/lib/block_list.c
index 15bb5cf..096dc9b 100644
--- a/lib/block_list.c
+++ b/lib/block_list.c
@@ -8,7 +8,7 @@
 #include <sys/stat.h>
 #include "erofs/block_list.h"
 
-#define pr_fmt(fmt) "EROFS block_list: " FUNC_LINE_FMT fmt "\n"
+#define EROFS_MODNAME  "erofs block_list"
 #include "erofs/print.h"
 
 static FILE *block_list_fp;
diff --git a/lib/io.c b/lib/io.c
index 03c7e33..cfc062d 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -20,7 +20,7 @@
 #include <linux/falloc.h>
 #endif
 
-#define pr_fmt(fmt) "EROFS IO: " FUNC_LINE_FMT fmt "\n"
+#define EROFS_MODNAME  "erofs_io"
 #include "erofs/print.h"
 
 static const char *erofs_devname;
-- 
2.24.4

Reply via email to