-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce stringification with a new bonus feature
- Loading branch information
Showing
2 changed files
with
77 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <inttypes.h> // PRI* | ||
#include <stdio.h> // printf | ||
|
||
#define MARKDOWN_HEADER "|Level|File|Function|Line|Message|\n|:-|:-|:-|-:|:-|\n" | ||
|
||
#define log_log(LEVEL, MESSAGE, ...) \ | ||
printf("|" LEVEL "|`" __FILE__ "`|`%s`|%i|" MESSAGE "\n", \ | ||
__func__, \ | ||
__LINE__ __VA_OPT__(, ) __VA_ARGS__) | ||
|
||
#define log_debug(MESSAGE, ...) \ | ||
log_log("DEBUG", MESSAGE __VA_OPT__(, ) __VA_ARGS__) | ||
|
||
#define log_debug_eval_1(VARIABLE) log_debug("%s = %i", #VARIABLE, VARIABLE) | ||
#define log_debug_eval_2(VARIABLE) log_debug(#VARIABLE " = %i", VARIABLE) | ||
#define log_debug_eval_3(FORMAT, VARIABLE) \ | ||
log_debug(#VARIABLE " = " FORMAT, VARIABLE) | ||
#define log_debug_eval_4(FLAG, VARIABLE) \ | ||
log_debug(#VARIABLE " = %" FLAG, VARIABLE) | ||
|
||
int main(int arg_count, char** arg_values) | ||
{ | ||
printf(MARKDOWN_HEADER); | ||
log_debug_eval_1(arg_count); | ||
log_debug_eval_2(arg_count); | ||
log_debug_eval_3("%p", arg_values); | ||
log_debug_eval_4(PRIXPTR, arg_values); | ||
} |