Skip to content

Commit

Permalink
Merge pull request #121 from marcone/logs
Browse files Browse the repository at this point in the history
Make PRINT_* macros behave consistently
  • Loading branch information
jfdelnero authored Nov 18, 2024
2 parents f5ef898 + 4a1bdd4 commit c479e35
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions inc/logs_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,42 +63,42 @@ void timestamp(char * timestr, int maxsize);

#else // Stdout usage

#define PRINT_MSG(fmt, args...) { \
#define PRINT_MSG(fmt, args...) do { \
char timestr[32]; \
timestamp((char*)&timestr, sizeof(timestr)); \
fprintf(stdout, \
"[uMTPrd - %s - Info] " fmt "\n",(char*)&timestr, \
## args); \
fflush(stdout); \
}
} while (0)

#define PRINT_ERROR(fmt, args...) { \
#define PRINT_ERROR(fmt, args...) do { \
char timestr[32]; \
timestamp((char*)&timestr, sizeof(timestr)); \
fprintf(stderr, \
"[uMTPrd - %s - Error] " fmt "\n",(char*)&timestr, \
## args); \
fflush(stderr); \
}
} while (0)

#define PRINT_WARN(fmt, args...) { \
#define PRINT_WARN(fmt, args...) do { \
char timestr[32]; \
timestamp((char*)&timestr, sizeof(timestr)); \
fprintf(stdout, \
"[uMTPrd - %s - Warning] " fmt "\n",(char*)&timestr, \
## args); \
fflush(stdout); \
}
} while (0)

#ifdef DEBUG
#define PRINT_DEBUG(fmt, args...) { \
#define PRINT_DEBUG(fmt, args...) do { \
char timestr[32]; \
timestamp((char*)&timestr, sizeof(timestr)); \
fprintf(stdout, \
"[uMTPrd - %s - Debug] " fmt "\n",(char*)&timestr, \
## args); \
fflush(stdout); \
}
} while (0)
#else

#define PRINT_DEBUG(fmt, args...)
Expand Down

0 comments on commit c479e35

Please sign in to comment.