0
должен я пытаюсь управлять моим собственным Debug system
на Qt
, но у меня есть некоторые вопросы:#define отображается выход, где он не
main.h
#include <QCoreApplication>
#include "PhTools/PhDebug.h"
int main(int argc, char *argv[])
{
// Test of Debug tool
DEBUG << "Test";
// Test of TimeCode
for(int i=0; i<3;i++)
{
if(false)
DEBUG << "problem with me";
}
return 0;
}
PhDebug.h
#ifndef PHDEBUG_H
#define PHDEBUG_H
#include <QDebug>
#include <QDate>
#include <QRect>
#define DEBUG PhDebug d; d << PHDEBUG
#define PHDEBUG qDebug() << __FUNCTION__ << ":"
// In order to get rid of double quotes when displaying a variable
#define Q(string) (string).toStdString().c_str()
class PhDebug
{
public:
QDebug operator<<(QDebug dbg)
{
QString d;
d = QDate::currentDate().toString("dd.MM.yyyy");
d += " - ";
d += QTime::currentTime().toString("hh.mm.ss.zzz");
d += " in";
dbg << Q(d);
return dbg;
}
};
#endif // PHDEBUG_H
Таким образом, выход должен быть 04.09.2013 - 12.30.51.513 in main : Test
, но вместо этого у меня есть:
04.09.2013 - 12.30.51.513 in main : Test
04.09.2013 - 12.30.51.514 in main : problem with me
04.09.2013 - 12.30.51.514 in main : problem with me
04.09.2013 - 12.30.51.514 in main : problem with me