X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=trace.h;h=870bd87ce03a2d9f7db322e19e30744ed84dc4c0;hb=166f29f9d4d6e2ed8080e78d38f45edd68315be4;hp=b79ea30023c8133a20c2577e1ca5d822f55ab42e;hpb=5aab04fb31d062324481169954a27de738619425;p=dorian diff --git a/trace.h b/trace.h index b79ea30..870bd87 100644 --- a/trace.h +++ b/trace.h @@ -1,54 +1,42 @@ #ifndef TRACE_H #define TRACE_H +#include #include #include #include #include +#include +#ifdef Q_OS_SYMBIAN +# ifdef __PRETTY_FUNCTION__ +# define TRACE Trace _(__PRETTY_FUNCTION__) +# else +# define TRACE Trace _(__FUNCTION__) +# endif +#else +# define TRACE Trace _(Q_FUNC_INFO) +#endif + +/** Trace helper. */ class Trace { public: - Trace(const QString &s): name(s) { - qDebug() << prefix() + ">" + name; - indent++; - } - ~Trace() { - if (--indent < 0) { - indent = 0; - } - qDebug() << prefix() + "<" + name; - } - void trace(const QString &s) const { - qDebug() << prefix() + name + ": " + s; - } - - static void debug(const QString &s) { - qDebug() << prefix() + s; - } - - static QString event(QEvent::Type t) { - for (int i = 0; eventTab[i].name; i++) { - if (eventTab[i].type == t) { - return eventTab[i].name; - } - } - if (t >= QEvent::User) { - return QString("QEvent::User+%1").arg(t - QEvent::User); - } else { - return QString("Unknown event %1").arg(t); - } - } + Trace(const QString &s); + ~Trace(); + static QString event(QEvent::Type t); + static void messageHandler(QtMsgType type, const char *msg); + static QtMsgType level; + static void setFileName(const QString &fileName); + static QString fileName(); protected: - static QString prefix() { - return QTime::currentTime().toString("hh:mm:ss.zzz ") + - QString(" ").repeated(indent); - } + static QString prefix(); QString name; static int indent; typedef struct {int type; const char *name;} EventName; static EventName eventTab[]; + static QFile file; }; #endif // TRACE_H