hgcacheproxymodel/inc/hglogger.h
changeset 1 e48454f237ca
child 17 a10844a9914d
equal deleted inserted replaced
0:89c329efa980 1:e48454f237ca
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 *  Version     : %version: 1 %
       
    17 */
       
    18 #ifndef HGLOGGER_H_
       
    19 #define HGLOGGER_H_
       
    20 
       
    21 //To enable tracking define ENABLETRACE
       
    22 //if TRACE_FILENAME is set then trace will go to file, otherwise to RDebug
       
    23 
       
    24 #include <QObject>
       
    25 #include <qglobal.h>
       
    26 
       
    27 #define XQCONNECT_ASSERT(a, b, c, d) if (!(QObject::connect((a),(b), (c), (d)))) { qFatal("Connection failed: connect(%s, %s, %s, %s)", #a, #b, #c, #d); }
       
    28 
       
    29 // stolen from qt-music :)
       
    30 #ifdef ENABLETRACE
       
    31     #include <QString>
       
    32     #include <QDebug>
       
    33     #include <QTime>
       
    34     #include <stdio.h>
       
    35     #include <stdlib.h>
       
    36     #include <e32debug.h>
       
    37 
       
    38     #ifdef TRACE_FILE
       
    39         #define _TRACE_FILENAME "c:/trace.txt"
       
    40         #define _TX_INIT void __tx_myMessageOutput(QtMsgType type, const char *msg) {\
       
    41              static const QString timeFmt("hh:mm:ss.zzz");\
       
    42              FILE *f = fopen(_TRACE_FILENAME, "a");\
       
    43              fprintf(f, "%s ", QTime::currentTime().toString(timeFmt).toLatin1().data() );\
       
    44              switch (type) {\
       
    45              case QtDebugMsg: fprintf(f, "[DEB] [TX] %s\n", msg); break;\
       
    46              case QtWarningMsg: fprintf(f, "[WRN] [TX] %s\n", msg); break;\
       
    47              case QtCriticalMsg: fprintf(f, "[CRT] [TX] %s\n", msg); break;\
       
    48              case QtFatalMsg: fprintf(f, "[FTL] [TX] %s\n", msg); fclose(f); abort();\
       
    49              } fclose(f);\
       
    50         }
       
    51     #else
       
    52         #define _TX_INIT void __tx_myMessageOutput(QtMsgType /*type*/, const char *msg) {\
       
    53             RDebug::Printf("[TX] %s", msg);\
       
    54             }
       
    55     #endif // TRACE_FILE
       
    56 
       
    57     #define _TX_INSTALL qInstallMsgHandler(__tx_myMessageOutput);
       
    58     #define TX_MAIN(a, b) _TX_INIT \
       
    59             int __tx__main(int, char**); int main(int (a), char **(b)) { _TX_INSTALL return __tx__main(a, b); } int __tx__main(int (a), char **(b))
       
    60 
       
    61     #define TX_UNUSED(name);
       
    62     #define TX_STATIC_ENTRY qDebug() << __PRETTY_FUNCTION__  << "entry";
       
    63     #define TX_STATIC_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "entry," << args;
       
    64     #define TX_STATIC_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit";
       
    65     #define TX_STATIC_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args; 
       
    66     #define TX_ENTRY qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry";
       
    67     #define TX_ENTRY_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this << "entry," << args;
       
    68     #define TX_EXIT qDebug() << __PRETTY_FUNCTION__ << "exit";
       
    69     #define TX_EXIT_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << "exit," << args;
       
    70     #define TX_LOG qDebug() << __PRETTY_FUNCTION__ << "this" << (void *)this;
       
    71     #define TX_LOG_ARGS(args) qDebug() << __PRETTY_FUNCTION__ << args;
       
    72 #else
       
    73     #define TX_MAIN(a,b) int main(int (a), char **(b))
       
    74     #define TX_UNUSED(name) Q_UNUSED(name);
       
    75     #define TX_STATIC_ENTRY ;
       
    76     #define TX_STATIC_ENTRY_ARGS(args) ;
       
    77     #define TX_STATIC_EXIT ;
       
    78     #define TX_STATIC_EXIT_ARGS(args) ;
       
    79     #define TX_ENTRY ;
       
    80     #define TX_ENTRY_ARGS(args) ;
       
    81     #define TX_EXIT ;
       
    82     #define TX_EXIT_ARGS(args) ;
       
    83     #define TX_LOG ;
       
    84     #define TX_LOG_ARGS(args) ;
       
    85 #endif // ENABLETRACE
       
    86 
       
    87 
       
    88 #endif // HGLOGGER_H_