base: Reimplement the DPRINTF mechanism in a Logger class
This patch adds a Logger class encapsulating dprintf. This allows variants of DPRINTF logging to be constructed and substituted in place of the default behaviour. The Logger provides a logMessage(when, name, format, ...) member function like Trace::dprintf and a getOstream member function to use a raw ostream for logging. A class OstreamLogger is provided which generates the customary debugging output with Trace::OstreamLogger::logMessage being the old Trace::dprintf.
This commit is contained in:
@@ -33,17 +33,25 @@
|
||||
%{
|
||||
#include "base/trace.hh"
|
||||
#include "base/types.hh"
|
||||
#include "base/output.hh"
|
||||
|
||||
inline void
|
||||
output(const char *filename)
|
||||
{
|
||||
Trace::setOutput(filename);
|
||||
std::ostream *file_stream = simout.find(filename);
|
||||
|
||||
if (!file_stream)
|
||||
file_stream = simout.create(filename);
|
||||
|
||||
Trace::setDebugLogger(new Trace::OstreamLogger(*file_stream));
|
||||
}
|
||||
|
||||
inline void
|
||||
ignore(const char *expr)
|
||||
{
|
||||
Trace::ignore.setExpression(expr);
|
||||
ObjectMatch ignore(expr);
|
||||
|
||||
Trace::getDebugLogger()->setIgnore(ignore);
|
||||
}
|
||||
|
||||
using Trace::enabled;
|
||||
|
||||
Reference in New Issue
Block a user