Commit 3832f75c authored by Dominik Charousset's avatar Dominik Charousset

print errors and warning if compiled w/o logging

parent 8be5138a
......@@ -32,6 +32,7 @@
#define CPPA_LOGGING_HPP
#include <sstream>
#include <iostream>
#include "cppa/singletons.hpp"
#include "cppa/detail/demangle.hpp"
......@@ -106,7 +107,9 @@ class logging {
#define CPPA_VOID_STMT static_cast<void>(0)
#ifndef CPPA_LOG_LEVEL
# define CPPA_LOG(classname, funname, level, message) CPPA_VOID_STMT
# define CPPA_LOG(classname, funname, level, message) \
std::cerr << level << " [" << classname << "::" << funname << "]: " \
<< message << std::endl;
# define CPPA_LIF(stmt, logstmt) CPPA_VOID_STMT
#else
# define CPPA_LOG(classname, funname, level, message) { \
......@@ -119,22 +122,18 @@ class logging {
#define CPPA_CLASS_NAME ::cppa::detail::demangle(typeid(*this)).c_str()
// errors and warnings are enabled by default
/**
* @brief Logs a custom error message @p msg with class name @p cname
* and function name @p fname.
*/
#define CPPA_LOGC_ERROR(cname, fname, msg) CPPA_LOG(cname, fname, "ERROR", msg)
#define CPPA_LOGC_WARNING(cname, fname, msg) CPPA_VOID_STMT
#define CPPA_LOGC_WARNING(cname, fname, msg) CPPA_LOG(cname, fname, "WARN ", msg)
#define CPPA_LOGC_INFO(cname, fname, msg) CPPA_VOID_STMT
#define CPPA_LOGC_DEBUG(cname, fname, msg) CPPA_VOID_STMT
#define CPPA_LOGC_TRACE(cname, fname, msg) CPPA_VOID_STMT
// enable warnings
#if CPPA_LOG_LEVEL > 0
# undef CPPA_LOGC_WARNING
# define CPPA_LOGC_WARNING(cname, fname, msg) CPPA_LOG(cname, fname, "WARN ", msg)
#endif
// enable info messages
#if CPPA_LOG_LEVEL > 1
# undef CPPA_LOGC_INFO
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment