add time logging

This commit is contained in:
arcan1s 2015-06-18 00:47:27 +03:00
parent 9be4fe3681
commit 1a4e071b5b
2 changed files with 41 additions and 0 deletions

35
pdebug.cpp Normal file
View File

@ -0,0 +1,35 @@
/***************************************************************************
* Copyright (C) 2014 Evgeniy Alekseev *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 3.0 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library. *
***************************************************************************/
#include <pdebug.h>
#if QT_VERSION >= 0x050000
void debugString(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_UNUSED(context)
Q_UNUSED(type)
QByteArray localMsg = msg.toLocal8Bit();
QByteArray timeNow = QDateTime::currentDateTime().toString(QString("yyyy-MM-ddTHH:mm:ss.zzzZ")).toLocal8Bit();
fprintf(stderr, "[%s]%s\n", timeNow.constData(), localMsg.constData());
}
#endif

View File

@ -44,4 +44,10 @@ inline std::string pFuncInfo(const std::string prettyFunction)
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
#if QT_VERSION >= 0x050000
#include <QDateTime>
void debugString(QtMsgType type, const QMessageLogContext &context, const QString &msg);
#endif /* QT_VERSION >= 0x050000 */
#endif /* PRETTY_DEBUG_H */