Created
January 23, 2018 15:22
-
-
Save RDCH106/cbfb7c36cdd509d9b370d39f13edf4ac to your computer and use it in GitHub Desktop.
C++ logger with logging levels (standard output)
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
#pragma once | |
#if defined(___LOG_DEBUG) | |
# include <iostream> | |
# define LOGD(...) std::cout << " " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGI(...) std::cout << " " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGW(...) std::cout << " * Warning: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGE(...) std::cout << " *** Error: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
#elif defined(___LOG_INFO) | |
# include <iostream> | |
# define LOGD(...) | |
# define LOGI(...) std::cout << " " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGW(...) std::cout << " * Warning: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGE(...) std::cout << " *** Error: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
#elif defined(___LOG_WARNING) | |
# include <iostream> | |
# define LOGD(...) | |
# define LOGI(...) | |
# define LOGW(...) std::cout << " * Warning: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
# define LOGE(...) std::cout << " *** Error: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
#elif defined(___LOG_ERROR) | |
# include <iostream> | |
# define LOGD(...) | |
# define LOGI(...) | |
# define LOGW(...) | |
# define LOGE(...) std::cout << " *** Error: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl; | |
#else | |
// NO LOGS | |
# define LOGV(...) | |
# define LOGD(...) | |
# define LOGI(...) | |
# define LOGW(...) | |
# define LOGE(...) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment