logsui/inc/logslogger.h
changeset 0 4a5361db8937
child 15 76d2cf7a585e
equal deleted inserted replaced
-1:000000000000 0:4a5361db8937
       
     1 /*
       
     2 * Copyright (c) 2006 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef LOGSLOGGER_H
       
    20 #define LOGSLOGGER_H
       
    21 
       
    22 #include <QDebug>
       
    23 
       
    24 
       
    25 // Disabled PC_lint warning for "Undefined preprocessor variable 'UNIT_TESTING'"
       
    26 //lint -e553 
       
    27 #if ( !defined(_DEBUG) || defined(QT_NO_DEBUG_OUTPUT) ) // release or unit test build; no logs
       
    28 
       
    29 #define LOGS_QDEBUG( a )
       
    30 #define LOGS_QDEBUG_2( a, b)
       
    31 #define LOGS_QDEBUG_3( a, b, c)
       
    32 #define LOGS_QDEBUG_4( a, b, c, d)
       
    33 #define LOGS_QDEBUG_5( a, b, c, d, e)
       
    34 #define LOGS_QWARNING( a )
       
    35 #define LOGS_QWARNING_2( a, b )
       
    36 #define LOGS_QCRITICAL( a )
       
    37 #define LOGS_QCRITICAL_2( a, b )
       
    38 #define LOGS_QCRITICAL_3( a, b, c)
       
    39 #define LOGS_QDEBUG_EVENT( ev )
       
    40 #define LOGS_QDEBUG_EVENT_ARR( arr )
       
    41 
       
    42 #else // debug build; logs
       
    43 
       
    44 
       
    45 const char logsDebugPrefix[]    = "Debug: ";
       
    46 const char logsWarningPrefix[]  = "Warning: ";
       
    47 const char logsCriticalPrefix[] = "Critical: ";
       
    48 const char logsFatalPrefix[]    = "Fatal: ";
       
    49 
       
    50 #include <e32debug.h>    // RDebug
       
    51 #include <QFile>
       
    52 #include <QTextStream>
       
    53 #include <qapplication.h>
       
    54 #include <stdio.h>
       
    55 #include <stdlib.h>
       
    56 
       
    57 const char logsLogFile[] = "C:/logs/logsapp/logsappdebug.txt";// Logs application log filename.
       
    58 
       
    59 
       
    60 #define LOGS_QDEBUG( a )\
       
    61     qDebug() << a;
       
    62 
       
    63 #define LOGS_QDEBUG_2( a, b)\
       
    64     qDebug() << a << b;
       
    65 
       
    66 #define LOGS_QDEBUG_3( a, b, c)\
       
    67     qDebug() << a << b << c;
       
    68 
       
    69 #define LOGS_QDEBUG_4( a, b, c, d)\
       
    70     qDebug() << a << b << c << d;
       
    71 
       
    72 #define LOGS_QDEBUG_5( a, b, c, d, e)\
       
    73     qDebug() << a << b << c << d << e;
       
    74 
       
    75 #define LOGS_QWARNING( a )\
       
    76     qWarning() << a;
       
    77 
       
    78 #define LOGS_QWARNING_2( a, b )\
       
    79     qWarning() << a << b;      
       
    80 
       
    81 #define LOGS_QCRITICAL( a )\
       
    82     qCritical() << a;  
       
    83 
       
    84 #define LOGS_QCRITICAL_2( a, b )\
       
    85     qCritical() << a << b;  
       
    86     
       
    87 #define LOGS_QCRITICAL_3( a, b, c)\
       
    88     qCritical() << a << b << c;
       
    89 
       
    90 // Event logging can be disabled by commenting line below
       
    91 #define LOGS_EVENT_LOGGING_ENABLED
       
    92 
       
    93 #ifdef LOGS_EVENT_LOGGING_ENABLED
       
    94 #define LOGS_QDEBUG_EVENT( ev ) \
       
    95     qDebug() << "Logs event index:" << ev->index() << "type:" << ev->eventType() \
       
    96     << "dir:" << ev->direction() << "remote:" << ev->remoteParty() << "num:" << ev->number() \
       
    97     << "inView:" << ev->isInView() << "state:" << ev->eventState();
       
    98 
       
    99 #define LOGS_QDEBUG_EVENT_ARR( arr )\
       
   100     qDebug() << "Logs event arr:";\
       
   101     foreach( LogsEvent* e, arr ) { \
       
   102     LOGS_QDEBUG_EVENT( e ) }
       
   103 #else
       
   104 #define LOGS_QDEBUG_EVENT( ev )
       
   105 #define LOGS_QDEBUG_EVENT_ARR( arr )
       
   106 #endif
       
   107 
       
   108 // File logging can be disabled by commenting definition below. 
       
   109 #define LOGS_FILE_LOGGING_ENABLED
       
   110 
       
   111 #if ( defined __WINSCW__ ) || ( defined __WINS__ )
       
   112 // No sense to have file logging enabled in wins
       
   113 #undef LOGS_FILE_LOGGING_ENABLED
       
   114 #endif
       
   115 
       
   116 #ifdef LOGS_FILE_LOGGING_ENABLED
       
   117 const bool logsFileLoggingEnabled = ETrue;
       
   118 #else
       
   119 const bool logsFileLoggingEnabled = EFalse;
       
   120 #endif
       
   121 
       
   122 
       
   123 #endif
       
   124 
       
   125 #endif // LOGSLOGGER_H
       
   126 
       
   127 // End of File