Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
add macro block
Browse files Browse the repository at this point in the history
  • Loading branch information
waynz0r committed Apr 30, 2024
1 parent 709442f commit c76460b
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions include/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,29 @@ char *compose_log_message(const char *message, int n, ...);

int send_trace(const tcp_connection_context *conn_ctx, const char *message, int log_level, int n, ...);

#define trace_log(conn_ctx, message, log_level, n, ...) \
char *log_message = compose_log_message(message, n, ##__VA_ARGS__); \
if (!IS_ERR(log_message)) \
{ \
switch (log_level) \
{ \
case LOGLEVEL_ERR: \
pr_err("%s", log_message); \
break; \
case LOGLEVEL_WARNING: \
pr_warn("%s", log_message); \
break; \
case LOGLEVEL_INFO: \
pr_info("%s", log_message); \
break; \
case LOGLEVEL_DEBUG: \
pr_debug("%s", log_message); \
break; \
} \
kfree(log_message); \
} \
#define trace_log(conn_ctx, message, log_level, n, ...) \
{ \
char *log_message = compose_log_message(message, n, ##__VA_ARGS__); \
if (!IS_ERR(log_message)) \
{ \
switch (log_level) \
{ \
case LOGLEVEL_ERR: \
pr_err("%s", log_message); \
break; \
case LOGLEVEL_WARNING: \
pr_warn("%s", log_message); \
break; \
case LOGLEVEL_INFO: \
pr_info("%s", log_message); \
break; \
case LOGLEVEL_DEBUG: \
pr_debug("%s", log_message); \
break; \
} \
kfree(log_message); \
} \
} \
send_trace(conn_ctx, message, log_level, n, ##__VA_ARGS__);

#define trace_err(conn_ctx, message, n, ...) \
Expand Down

0 comments on commit c76460b

Please sign in to comment.