Last active
August 29, 2015 14:01
-
-
Save abstractOwl/e512ce07925e5e38b08e to your computer and use it in GitHub Desktop.
Simple C Logging Library
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
#include <stdio.h> | |
#define LOG_NONE (0) | |
#define LOG_WARN (1) | |
#define LOG_INFO (2) | |
#define WARN(...) | |
#define INFO(...) | |
#define LOG_LEVEL LOG_INFO // Set log level here | |
#define LOG(msg, args...) \ | |
do { \ | |
printf("[%s] (%s:%d) " msg "\n", __func__, __FILE__, __LINE__, ##args); \ | |
} while (0) | |
#if LOG_LEVEL >= LOG_WARN | |
#undef WARN | |
#define WARN(msg, args...) LOG("WARN - " msg, ##args) | |
#endif | |
#if LOG_LEVEL >= LOG_INFO | |
#undef INFO | |
#define INFO(msg, args...) LOG("INFO - " msg, ##args) | |
#endif | |
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
#include <stdio.h> | |
#define DEBUG | |
#ifdef DEBUG | |
#define LOG(...) printf(__VA_ARGS__); | |
#endif |
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
#include <stdio.h> | |
#define LOG_NONE (0) | |
#define LOG_WARN (1) | |
#define LOG_INFO (2) | |
#define WARN(...) | |
#define INFO(...) | |
#define LOG_LEVEL LOG_WARN // Set log level here | |
#if LOG_LEVEL >= LOG_WARN | |
#undef WARN | |
#define WARN(msg, args...) printf("[WARN] " msg, ##args) | |
#endif | |
#if LOG_LEVEL >= LOG_INFO | |
#undef INFO | |
#define INFO(msg, args...) printf("[INFO] " msg, ##args) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment