8
#define LOG4CPP_FIX_ERROR_COLLISION 1
9
#include <log4cpp/Category.hh>
10
#include <log4cpp/FileAppender.hh>
11
#include <log4cpp/PatternLayout.hh>
12
#include <log4cpp/OstreamAppender.hh>
16
* Wrapper used by the application to handle the log/trace
17
* messages by means of the log4cpp library.
22
log4cpp::Category *category;
23
log4cpp::Appender *appender;
24
log4cpp::PatternLayout *layout;
25
log4cpp::Appender *file_appender;
26
log4cpp::PatternLayout *file_layout;
28
static TraceSystem traceSystem;
31
virtual ~TraceSystem();
33
bool AppendToFile_(const char *name);
36
static bool AppendToFile(const char *name)
38
return traceSystem.AppendToFile_(name);
41
static bool AppendToFile(const std::string& name)
43
return traceSystem.AppendToFile_(name.c_str());
46
static log4cpp::CategoryStream logStream()
48
return traceSystem.category->infoStream();
51
static log4cpp::CategoryStream errorStream()
53
return traceSystem.category->errorStream();
56
static log4cpp::CategoryStream traceStream()
58
return traceSystem.category->debugStream();
69
#define _SET_COLOR(a) "\033[" a
70
#define _RESET_COLOR() "\033[0m"
72
#define _SET_COLOR(a) ""
73
#define _RESET_COLOR() ""
77
#define LOG(a) (TraceSystem::logStream() << a << log4cpp::eol)
78
#define LOGC(c, a) (TraceSystem::logStream() << _SET_COLOR(c) << a << _RESET_COLOR() << log4cpp::eol)
79
#define ERROR(a) (TraceSystem::errorStream() << _SET_COLOR(_RED) << __FILE__ << ":" << __LINE__ << ": ERROR: " << a << _RESET_COLOR() << log4cpp::eol)
86
#if defined(SHOW_TRACES) && !defined(NDEBUG) && !defined(SILENT_MODE)
87
#define TRACE(a) (TraceSystem::traceStream() << _SET_COLOR(_YELLOW) << __FILE__ << ":" << __LINE__ << ": TRACE: " << a << _RESET_COLOR() << log4cpp::eol)
92
#define CERR(a) (cerr << _SET_COLOR(_RED) << a << "!" << _RESET_COLOR() << endl, -1)