File indexing completed on 2024-05-12 16:42:41

0001 /*
0002     SPDX-FileCopyrightText: 2010 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef MYMONEYTRACER_H
0008 #define MYMONEYTRACER_H
0009 
0010 #include "kmm_mymoney_export.h"
0011 
0012 #include "qglobal.h"
0013 
0014 #ifdef __GNUC__
0015 #  define KMM_PRINTF_FORMAT(x, y) __attribute__((format(__printf__, x, y)))
0016 #else
0017 #  define KMM_PRINTF_FORMAT(x, y) /*NOTHING*/
0018 #endif
0019 
0020 class QString;
0021 
0022 void timestamp(const char* txt);
0023 void timestamp_reset();
0024 
0025 class MyMoneyTracerPrivate;
0026 class KMM_MYMONEY_EXPORT MyMoneyTracer
0027 {
0028     Q_DISABLE_COPY(MyMoneyTracer)
0029 
0030 public:
0031     explicit MyMoneyTracer(const char* prettyName);
0032 #define MYMONEYTRACER(a) MyMoneyTracer a(Q_FUNC_INFO)
0033 
0034     explicit MyMoneyTracer(const QString& className, const QString& methodName);
0035     ~MyMoneyTracer();
0036 
0037     /**
0038       * This method allows to trace a printf like formatted text
0039       *
0040       * @param format format mask
0041       */
0042     void printf(const char *format, ...) const KMM_PRINTF_FORMAT(2, 3);
0043 
0044     static void off();
0045     static void on();
0046     static void onOff(int onOff);
0047 
0048 private:
0049     MyMoneyTracerPrivate * const d_ptr;
0050     Q_DECLARE_PRIVATE(MyMoneyTracer)
0051 };
0052 
0053 #endif