Skip to content

Commit

Permalink
Merge pull request #154 from marktwtn/simplify-printing-debug-message
Browse files Browse the repository at this point in the history
refactor: Simplification of output debug messages
  • Loading branch information
jserv authored May 20, 2019
2 parents 4d39d44 + 4f0c94d commit 8e2038b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef COMMON_H_
#define COMMON_H_

#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>

#define __DCURL_MAJOR__ 0
Expand All @@ -10,6 +12,15 @@

double diff_in_second(struct timespec t1, struct timespec t2);

static inline void ddprintf(const char *format, ...) {
#if defined(ENABLE_DEBUG)
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
#endif
}

typedef struct _pow_info PoW_Info;

struct _pow_info {
Expand Down
6 changes: 2 additions & 4 deletions src/implcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ bool registerImplContext(ImplContext *impl_ctx)
bool initializeImplContext(ImplContext *impl_ctx)
{
bool res = impl_ctx->initialize(impl_ctx);
#if defined(ENABLE_DEBUG)
if (res) {
printf(MSG_PREFIX "Implementation %s is initialized successfully\n",
impl_ctx->description);
ddprintf(MSG_PREFIX "Implementation %s is initialized successfully\n",
impl_ctx->description);
}
#endif
return res;
}

Expand Down

0 comments on commit 8e2038b

Please sign in to comment.