From 1a4e071b5b41f1f832af1614006b418db6e2eff6 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Thu, 18 Jun 2015 00:47:27 +0300 Subject: [PATCH] add time logging --- pdebug.cpp | 35 +++++++++++++++++++++++++++++++++++ pdebug.h | 6 ++++++ 2 files changed, 41 insertions(+) create mode 100644 pdebug.cpp diff --git a/pdebug.cpp b/pdebug.cpp new file mode 100644 index 0000000..f83ebc6 --- /dev/null +++ b/pdebug.cpp @@ -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 + +#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 diff --git a/pdebug.h b/pdebug.h index afa67ed..030cacb 100644 --- a/pdebug.h +++ b/pdebug.h @@ -44,4 +44,10 @@ inline std::string pFuncInfo(const std::string prettyFunction) #define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__)) +#if QT_VERSION >= 0x050000 +#include +void debugString(QtMsgType type, const QMessageLogContext &context, const QString &msg); +#endif /* QT_VERSION >= 0x050000 */ + + #endif /* PRETTY_DEBUG_H */