From 8db1be2ba8dc66d3abf69a8360990c659bf28f16 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Tue, 27 Jul 2021 17:02:49 -0700 Subject: [PATCH] Squashed 'lib/pinelog/' changes from 321d9aa..bdee493 bdee493 Add preprocessor definition to disable traces 5b2686a Fix pinelog builds on MacOS 48bd049 Merge commit '9fa1a428a45eabff0122e199a687068f0e6280dd' into daemon 68d5aae Update README to include destructor attribute git-subtree-dir: lib/pinelog git-subtree-split: bdee493f0357eb0f3f6d4b792140de78999c828e --- README.md | 7 ++++--- bench_pinelog.c | 3 ++- pinelog.h | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 01923d6..c8423c2 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ a Git submodule or subtree. The default build of Pinelog uses an autotools generated `config.h` file, which includes checks for the following GCC attributes. If you don't care about these, then either create a dummy config.h which includes the macros -`HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR` and `HAVE_FUNC_ATTRIBUTE_FORMAT`, or use the -`AX_GCC_FUNC_ATTRIBUTE` macro to check for the `constructor` and `format` -attributes in your application's `configure.ac` file. +`HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR`, `HAVE_FUNC_ATTRIBUTE_DESTRUCTOR` and +`HAVE_FUNC_ATTRIBUTE_FORMAT`, or use the `AX_GCC_FUNC_ATTRIBUTE` macro to check +for the `constructor`, `destructor` and `format` attributes in your +application's `configure.ac` file. diff --git a/bench_pinelog.c b/bench_pinelog.c index e9d6b8b..419f61b 100644 --- a/bench_pinelog.c +++ b/bench_pinelog.c @@ -12,6 +12,7 @@ #include #include +#include #include #define BENCH_COUNT 100000 @@ -36,7 +37,7 @@ static void print_time_difference(const char *type, struct timespec *ts) tp_usec = timeper / 1000; tp_nsec = timeper % 1000; - printf("# %s %lu.%03lu\u03BCs/log (Total %lu.%09lds)\n", + printf("# %s %"PRIu64".%03"PRIu64"\u03BCs/log (Total %lu.%09lds)\n", type, tp_usec, tp_nsec, ret.tv_sec, ret.tv_nsec); } diff --git a/pinelog.h b/pinelog.h index dfd2b0c..b061922 100644 --- a/pinelog.h +++ b/pinelog.h @@ -165,11 +165,16 @@ void pinelog_log_message(int level, const char *file, int line, const char *fmt, } \ } while(0) +/* PINELOG_DISABLE_TRACE allows all traces to be compiled out */ +#ifndef PINELOG_DISABLE_TRACE #define PINELOG_TRACE(fmt, ...) do { \ if (PINELOG_LVL_TRACE <= pinelog_get_level()) { \ pinelog_log_message(PINELOG_LVL_TRACE, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \ } \ } while(0) +#else +#define PINELOG_TRACE(fmt, ...) do { } while(0) +#endif #ifdef __cplusplus }