forked from qicosmos/cinatra
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
91 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <iostream> | ||
namespace cinatra { | ||
struct null_logger_t { | ||
template <typename T> | ||
const null_logger_t& operator<<(T&&) const { | ||
return *this; | ||
} | ||
}; | ||
struct cout_logger_t { | ||
template <typename T> | ||
const cout_logger_t& operator<<(T&& t) const { | ||
std::cout << std::forward<T>(t); | ||
return *this; | ||
} | ||
~cout_logger_t() { std::cout << std::endl; } | ||
}; | ||
struct cerr_logger_t { | ||
template <typename T> | ||
const cerr_logger_t& operator<<(T&& t) const { | ||
std::cerr << std::forward<T>(t); | ||
return *this; | ||
} | ||
~cerr_logger_t() { std::cerr << std::endl; } | ||
}; | ||
|
||
constexpr inline cinatra::null_logger_t NULL_LOGGER; | ||
|
||
} // namespace cinatra | ||
|
||
#ifdef CINATRA_LOG_ERROR | ||
#else | ||
#define CINATRA_LOG_ERROR \ | ||
cerr_logger_t {} | ||
#endif | ||
|
||
#ifdef CINATRA_LOG_WARNING | ||
#else | ||
#ifndef NDEBUG | ||
#define CINATRA_LOG_WARNING \ | ||
cerr_logger_t {} | ||
#else | ||
#define CINATRA_LOG_WARNING NULL_LOGGER | ||
#endif | ||
#endif | ||
|
||
#ifdef CINATRA_LOG_INFO | ||
#else | ||
#ifndef NDEBUG | ||
#define CINATRA_LOG_INFO \ | ||
cout_logger_t {} | ||
#else | ||
#define CINATRA_LOG_INFO NULL_LOGGER | ||
#endif | ||
#endif | ||
|
||
#ifdef CINATRA_LOG_DEBUG | ||
#else | ||
#ifndef NDEBUG | ||
#define CINATRA_LOG_DEBUG \ | ||
cout_logger_t {} | ||
#else | ||
#define CINATRA_LOG_DEBUG NULL_LOGGER | ||
#endif | ||
#endif | ||
|
||
#ifdef CINATRA_LOG_TRACE | ||
#else | ||
#ifndef NDEBUG | ||
#define CINATRA_LOG_TRACE \ | ||
cout_logger_t {} | ||
#else | ||
#define CINATRA_LOG_TRACE NULL_LOGGER | ||
#endif | ||
#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