36 #ifndef __BASE_TRACE_HH__ 37 #define __BASE_TRACE_HH__ 59 template <
typename ...Args>
67 template <
typename ...Args>
69 const std::string &flag,
70 const char *fmt,
const Args &...args)
72 if (!name.empty() && ignore.
match(name))
74 std::ostringstream line;
81 const void *
d,
int len,
const std::string &flag);
85 const std::string &flag,
const std::string &message) = 0;
115 const std::string &flag,
const std::string &message)
override;
147 const std::string &
name();
157 Named(
const std::string &name_) : _name(name_) { }
160 const std::string &
name()
const {
return _name; }
175 #define DTRACE(x) (Debug::x) 177 #define DDUMP(x, data, count) do { \ 178 using namespace Debug; \ 180 Trace::getDebugLogger()->dump( \ 181 curTick(), name(), data, count, #x); \ 184 #define DPRINTF(x, ...) do { \ 185 using namespace Debug; \ 187 Trace::getDebugLogger()->dprintf_flag( \ 188 curTick(), name(), #x, __VA_ARGS__); \ 192 #define DPRINTFS(x, s, ...) do { \ 193 using namespace Debug; \ 195 Trace::getDebugLogger()->dprintf_flag( \ 196 curTick(), s->name(), #x, __VA_ARGS__); \ 200 #define DPRINTFR(x, ...) do { \ 201 using namespace Debug; \ 203 Trace::getDebugLogger()->dprintf_flag( \ 204 (Tick)-1, std::string(), #x, __VA_ARGS__); \ 208 #define DDUMPN(data, count) do { \ 209 Trace::getDebugLogger()->dump(curTick(), name(), data, count); \ 212 #define DPRINTFN(...) do { \ 213 Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__); \ 216 #define DPRINTFNR(...) do { \ 217 Trace::getDebugLogger()->dprintf((Tick)-1, std::string(), __VA_ARGS__); \ 220 #define DPRINTF_UNCONDITIONAL(x, ...) do { \ 221 Trace::getDebugLogger()->dprintf_flag( \ 222 curTick(), name(), #x, __VA_ARGS__); \ 227 #define DTRACE(x) (false) 228 #define DDUMP(x, data, count) do {} while (0) 229 #define DPRINTF(x, ...) do {} while (0) 230 #define DPRINTFS(x, ...) do {} while (0) 231 #define DPRINTFR(...) do {} while (0) 232 #define DDUMPN(data, count) do {} while (0) 233 #define DPRINTFN(...) do {} while (0) 234 #define DPRINTFNR(...) do {} while (0) 235 #define DPRINTF_UNCONDITIONAL(x, ...) do {} while (0) 239 #endif // __BASE_TRACE_HH__ void ccprintf(cp::Print &print)
std::ostream & getOstream() override
Return an ostream that can be used to send messages to the 'same place' as formatted logMessage messa...
const std::string & operator()() const
void dprintf_flag(Tick when, const std::string &name, const std::string &flag, const char *fmt, const Args &...args)
Log a single message with a flag prefix.
StringWrap(const std::string &s)
void setIgnore(ObjectMatch &ignore_)
Set objects to ignore.
const std::string & name()
bool match(const std::string &name) const
virtual std::ostream & getOstream()=0
Return an ostream that can be used to send messages to the 'same place' as formatted logMessage messa...
OstreamLogger(std::ostream &stream_)
uint64_t Tick
Tick count type.
Debug logging base class.
ObjectMatch ignore
Name match for objects to ignore.
void add(const ObjectMatch &other)
std::ostream & output()
Get the ostream from the current global logger.
void addIgnore(const ObjectMatch &ignore_)
Add objects to ignore.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
const std::string & name() const
Logging wrapper for ostreams with the format: <when>: <name>: <message-body>
virtual void logMessage(Tick when, const std::string &name, const std::string &flag, const std::string &message)=0
Log formatted message.
Logger * getDebugLogger()
Get the current global debug logger.
void enable()
Enable/disable debug logging.
void setDebugLogger(Logger *logger)
Delete the current global logger and assign a new one.
Named(const std::string &name_)
ObjectMatch contains a vector of expressions.
void dprintf(Tick when, const std::string &name, const char *fmt, const Args &...args)
Log a single message.
void dump(Tick when, const std::string &name, const void *d, int len, const std::string &flag)
Dump a block of data of length len.