Skip to content

Commit

Permalink
Prefix logger.h macros with erpc_
Browse files Browse the repository at this point in the history
  • Loading branch information
anujkaliaiitd committed Jun 22, 2020
1 parent 2ab3bc7 commit 184ea4e
Showing 1 changed file with 28 additions and 27 deletions.
55 changes: 28 additions & 27 deletions src/util/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,70 +34,71 @@ namespace erpc {
#define ERPC_LOG_DEFAULT_STREAM stdout

// Log messages with "reorder" or higher verbosity get written to
// trace_file_or_default_stream. This can be stdout for basic debugging, or
// erpc_trace_file_or_default_stream. This can be stdout for basic debugging, or
// eRPC's trace file for more involved debugging.

#define trace_file_or_default_stream trace_file
//#define trace_file_or_default_stream ERPC_LOG_DEFAULT_STREAM
#define erpc_trace_file_or_default_stream trace_file
//#define erpc_trace_file_or_default_stream ERPC_LOG_DEFAULT_STREAM

// If ERPC_LOG_LEVEL is not defined, default to the highest level so that
// YouCompleteMe does not report compilation errors
#ifndef ERPC_LOG_LEVEL
#define ERPC_LOG_LEVEL ERPC_LOG_LEVEL_CC
#endif

static void output_log_header(int level);

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_ERROR
#define ERPC_ERROR(...) \
output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_ERROR); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
#define ERPC_ERROR(...) \
erpc_output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_ERROR); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
fflush(ERPC_LOG_DEFAULT_STREAM)
#else
#define ERPC_ERROR(...) ((void)0)
#endif

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_WARN
#define ERPC_WARN(...) \
output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_WARN); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
#define ERPC_WARN(...) \
erpc_output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_WARN); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
fflush(ERPC_LOG_DEFAULT_STREAM)
#else
#define ERPC_WARN(...) ((void)0)
#endif

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_INFO
#define ERPC_INFO(...) \
output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_INFO); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
#define ERPC_INFO(...) \
erpc_output_log_header(ERPC_LOG_DEFAULT_STREAM, ERPC_LOG_LEVEL_INFO); \
fprintf(ERPC_LOG_DEFAULT_STREAM, __VA_ARGS__); \
fflush(ERPC_LOG_DEFAULT_STREAM)
#else
#define ERPC_INFO(...) ((void)0)
#endif

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_REORDER
#define ERPC_REORDER(...) \
output_log_header(trace_file_or_default_stream, ERPC_LOG_LEVEL_REORDER); \
fprintf(trace_file_or_default_stream, __VA_ARGS__); \
fflush(trace_file_or_default_stream)
#define ERPC_REORDER(...) \
erpc_output_log_header(erpc_trace_file_or_default_stream, \
ERPC_LOG_LEVEL_REORDER); \
fprintf(erpc_trace_file_or_default_stream, __VA_ARGS__); \
fflush(erpc_trace_file_or_default_stream)
#else
#define ERPC_REORDER(...) ((void)0)
#endif

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_TRACE
#define ERPC_TRACE(...) \
output_log_header(trace_file_or_default_stream, ERPC_LOG_LEVEL_TRACE); \
fprintf(trace_file_or_default_stream, __VA_ARGS__); \
fflush(trace_file_or_default_stream)
#define ERPC_TRACE(...) \
erpc_output_log_header(erpc_trace_file_or_default_stream, \
ERPC_LOG_LEVEL_TRACE); \
fprintf(erpc_trace_file_or_default_stream, __VA_ARGS__); \
fflush(erpc_trace_file_or_default_stream)
#else
#define ERPC_TRACE(...) ((void)0)
#endif

#if ERPC_LOG_LEVEL >= ERPC_LOG_LEVEL_CC
#define ERPC_CC(...) \
output_log_header(trace_file_or_default_stream, ERPC_LOG_LEVEL_CC); \
fprintf(trace_file_or_default_stream, __VA_ARGS__); \
fflush(trace_file_or_default_stream)
#define ERPC_CC(...) \
erpc_output_log_header(erpc_trace_file_or_default_stream, \
ERPC_LOG_LEVEL_CC); \
fprintf(erpc_trace_file_or_default_stream, __VA_ARGS__); \
fflush(erpc_trace_file_or_default_stream)
#else
#define ERPC_CC(...) ((void)0)
#endif
Expand All @@ -115,7 +116,7 @@ static std::string get_formatted_time() {
}

// Output log message header
static void output_log_header(FILE *stream, int level) {
static void erpc_output_log_header(FILE *stream, int level) {
std::string formatted_time = get_formatted_time();

const char *type;
Expand Down

0 comments on commit 184ea4e

Please sign in to comment.