diff options
author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2021-10-12 14:31:41 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@linux.alibaba.com> | 2021-10-13 09:03:51 +0800 |
commit | 2ebfa8246dba3a17aaa6014218cfed62092fb001 (patch) | |
tree | be6f10023faaba75094604ef9435d90a917b7fd0 /include | |
parent | 96a59540090c6376553ff6cd5a042efea53d2d50 (diff) | |
download | erofs-utils-2ebfa8246dba3a17aaa6014218cfed62092fb001.tar.gz |
erofs-utils: don't print source file information for non-debug version
There is no need for end users to know the function details.
Link: https://lore.kernel.org/r/20211012063141.115164-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/erofs/print.h | 73 |
1 files changed, 38 insertions, 35 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__) |