 |
Cerata
A library to generate structural hardware designs
|
42 inline void enable(std::function<CallbackSignature> callback) {
43 callback_ = std::move(callback);
47 inline bool IsEnabled() {
return callback_ ? true :
false; }
51 std::string
const &message,
52 char const *source_function,
53 char const *source_file,
56 callback_(level, message, source_function, source_file, line_number);
62 std::function<void(
LogLevel,
const std::string &,
char const *,
char const *,
int)> callback_;
72 #define CERATA_LOG(level, msg) \
73 if (CERATA_LOG_##level > CERATA_LOG_WARNING) { \
74 throw std::runtime_error(std::string(__FILE__) + ":" \
75 + std::string(__FUNCTION__) + ":" \
76 + std::to_string(__LINE__) + ":\n" + (msg)); \
78 logger().write(CERATA_LOG_##level, msg, __FUNCTION__, __FILE__, __LINE__); \
void(LogLevel, const std::string &, char const *, char const *, int) CallbackSignature
Signature of the callback function.
Contains every Cerata class, function, etc...
constexpr LogLevel CERATA_LOG_DEBUG
Debug level.
constexpr LogLevel CERATA_LOG_WARNING
Warning level.
void write(LogLevel level, std::string const &message, char const *source_function, char const *source_file, int line_number)
Write something using the logging callback function.
void enable(std::function< CallbackSignature > callback)
Enable the logger. Can only be done after the callback function was set.
constexpr LogLevel CERATA_LOG_FATAL
Fatal level; tool should exit.
constexpr LogLevel CERATA_LOG_ERROR
Error level.
Logger & logger()
Return the global Cerata logger.
int LogLevel
Type used for the logging level.
constexpr LogLevel CERATA_LOG_INFO
Information level.
bool IsEnabled()
Return true if callback was set, false otherwise.