Skip to content

Commit

Permalink
print errors and warning if compiled w/o logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Apr 16, 2013
1 parent 8be5138 commit 3832f75
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cppa/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define CPPA_LOGGING_HPP

#include <sstream>
#include <iostream>

#include "cppa/singletons.hpp"
#include "cppa/detail/demangle.hpp"
Expand Down Expand Up @@ -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) { \
Expand All @@ -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
Expand Down

0 comments on commit 3832f75

Please sign in to comment.