32 #ifndef __BASE_TRACE_HH__ 33 #define __BASE_TRACE_HH__ 55 template <
typename ...Args>
63 template <
typename ...Args>
65 const std::string &flag,
66 const char *fmt,
const Args &...args)
68 if (!name.empty() && ignore.
match(name))
70 std::ostringstream line;
77 const void *
d,
int len,
const std::string &flag);
81 const std::string &flag,
const std::string &message) = 0;
111 const std::string &flag,
const std::string &message)
override;
143 const std::string &
name();
153 Named(
const std::string &name_) : _name(name_) { }
156 const std::string &
name()
const {
return _name; }
171 #define DTRACE(x) (Debug::x) 173 #define DDUMP(x, data, count) do { \ 174 using namespace Debug; \ 176 Trace::getDebugLogger()->dump( \ 177 curTick(), name(), data, count, #x); \ 180 #define DPRINTF(x, ...) do { \ 181 using namespace Debug; \ 183 Trace::getDebugLogger()->dprintf_flag( \ 184 curTick(), name(), #x, __VA_ARGS__); \ 188 #define DPRINTFS(x, s, ...) do { \ 189 using namespace Debug; \ 191 Trace::getDebugLogger()->dprintf_flag( \ 192 curTick(), s->name(), #x, __VA_ARGS__); \ 196 #define DPRINTFR(x, ...) do { \ 197 using namespace Debug; \ 199 Trace::getDebugLogger()->dprintf_flag( \ 200 (Tick)-1, std::string(), #x, __VA_ARGS__); \ 204 #define DDUMPN(data, count) do { \ 205 Trace::getDebugLogger()->dump(curTick(), name(), data, count); \ 208 #define DPRINTFN(...) do { \ 209 Trace::getDebugLogger()->dprintf(curTick(), name(), __VA_ARGS__); \ 212 #define DPRINTFNR(...) do { \ 213 Trace::getDebugLogger()->dprintf((Tick)-1, std::string(), __VA_ARGS__); \ 216 #define DPRINTF_UNCONDITIONAL(x, ...) do { \ 217 Trace::getDebugLogger()->dprintf_flag( \ 218 curTick(), name(), #x, __VA_ARGS__); \ 223 #define DTRACE(x) (false) 224 #define DDUMP(x, data, count) do {} while (0) 225 #define DPRINTF(x, ...) do {} while (0) 226 #define DPRINTFS(x, ...) do {} while (0) 227 #define DPRINTFR(...) do {} while (0) 228 #define DDUMPN(data, count) do {} while (0) 229 #define DPRINTFN(...) do {} while (0) 230 #define DPRINTFNR(...) do {} while (0) 231 #define DPRINTF_UNCONDITIONAL(x, ...) do {} while (0) 235 #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.