@@ -3387,10 +3387,10 @@ std::string format(const char* fmt, T... args) {
33873387
33883388
33893389#include < chrono>
3390+ #include < iosfwd>
33903391#include < map>
33913392#include < string>
33923393#include < vector>
3393- #include < iosfwd>
33943394
33953395ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
33963396
@@ -3458,7 +3458,7 @@ namespace zeroerr {
34583458
34593459#define ZEROERR_LOG_EVERY_ (n, ACTION, ...) \
34603460 do { \
3461- unsigned counter = 0 ; \
3461+ static unsigned counter = 0 ; \
34623462 if (counter == 0 ) { \
34633463 counter = n; \
34643464 ACTION (__VA_ARGS__); \
@@ -3476,12 +3476,14 @@ namespace zeroerr {
34763476
34773477#define ZEROERR_LOG_IF_EVERY_ (n, cond, ACTION, ...) \
34783478 do { \
3479- unsigned counter = 0 ; \
3480- if (counter == 0 && (cond)) { \
3481- counter = n; \
3482- ACTION (__VA_ARGS__); \
3479+ if (cond) { \
3480+ static unsigned counter = 0 ; \
3481+ if (counter == 0 ) { \
3482+ counter = n; \
3483+ ACTION (__VA_ARGS__); \
3484+ } \
3485+ --counter; \
34833486 } \
3484- --counter; \
34853487 } while (0 )
34863488
34873489#define INFO_IF_EVERY_ (n, cond, ...) ZEROERR_LOG_IF_EVERY_(n, cond, ZEROERR_INFO, __VA_ARGS__)
@@ -3492,7 +3494,7 @@ namespace zeroerr {
34923494
34933495#define ZEROERR_LOG_FIRST (cond, ACTION, ...) \
34943496 do { \
3495- bool first = true ; \
3497+ static bool first = true ; \
34963498 if (first && (cond)) { \
34973499 first = false ; \
34983500 ACTION (__VA_ARGS__); \
@@ -3507,8 +3509,9 @@ namespace zeroerr {
35073509
35083510#define ZEROERR_LOG_FIRST_ (n, cond, ACTION, ...) \
35093511 do { \
3510- unsigned counter = n; \
3511- if (n-- && (cond)) { \
3512+ static unsigned counter = n; \
3513+ if (counter && (cond)) { \
3514+ counter--; \
35123515 ACTION (__VA_ARGS__); \
35133516 } \
35143517 } while (0 )
@@ -3605,24 +3608,24 @@ enum LogSeverity {
36053608
36063609/* *
36073610 * @brief LogInfo is a struct to store the meta data of the log message.
3608- * @details LogInfo is a struct to store the meta data of the log message.
3611+ * @details LogInfo is a struct to store the meta data of the log message.
36093612 * It contains filename, function, message, category, line number, size, and severity.
36103613 * Those data is initialized when the first log message is created using a static
36113614 * local variable in the function where the log message is put.
3612- *
3615+ *
36133616 * For example:
36143617 * void foo() {
36153618 * log("Hello, {name}!", "John");
36163619 * }
3617- *
3618- * The inner implementation could be considered as (not exactly
3620+ *
3621+ * The inner implementation could be considered as (not exactly
36193622 * since message is allocated from a pool):
36203623 * void foo() {
3621- * static LogInfo log_info{
3622- * __FILE__, __func__, "Hello, {name}!",
3623- * ZEROERR_LOG_CATEGORY,
3624- * __LINE__,
3625- * sizeof("Hello, world!"),
3624+ * static LogInfo log_info{
3625+ * __FILE__, __func__, "Hello, {name}!",
3626+ * ZEROERR_LOG_CATEGORY,
3627+ * __LINE__,
3628+ * sizeof("Hello, world!"),
36263629 * LogSeverity::INFO_l);
36273630 * LogMessage* logdata = new LogMessageImpl<std::string>("John");
36283631 * logdata->info = &log_info;
@@ -3876,11 +3879,11 @@ class LogStream {
38763879 * The log message is structured as a tuple of the arguments in the inner
38773880 * implementation class LogMessageImpl. After the log message is created, it
38783881 * used type erasure to return a LogMessage pointer to the caller.
3879- *
3882+ *
38803883 * The stored data type is determined by the to_store_type_t<T> template.
38813884 * For all the string type in raw pointer like const char* or char[],
38823885 * it will be converted to std::string.
3883- * All reference type (including right value reference) will be converted
3886+ * All reference type (including right value reference) will be converted
38843887 * to the original type.
38853888 */
38863889 template <typename ... T>
0 commit comments