erofs-utils: don't print source file information for non-debug version
PATCH 1/1 erofs-utils: don't print source file information for non-debug version
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(-)
include/erofs/print.h +38 -35
@@ -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__)
lib/block_list.c +1 -1
@@ -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;
lib/io.c +1 -1
@@ -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;
Signature · 1 line
2.24.4