predictivesearch/PcsUtils/inc/CPcsDebug.h
changeset 0 e686773b3f54
child 6 e8e3147d53eb
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007 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:  PCS Server Debug macros
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __PCS_DEBUG_H__
       
    19 #define __PCS_DEBUG_H__
       
    20 
       
    21 #include <e32svr.h>
       
    22 #include <e32std.h>
       
    23 #include <badesca.h>
       
    24 #include <f32file.h>
       
    25 
       
    26 
       
    27 #ifdef _DEBUG
       
    28 
       
    29 #ifdef __WINS__
       
    30 #define PRINT( txt )                                \
       
    31     { TBuf<512> __buf; __buf.Format(txt);                          RDebug::Print( _L("[PCS] %S"), &__buf );  }
       
    32 #define PRINT1( txt, arg1 )                         \
       
    33     { TBuf<512> __buf; __buf.Format(txt,arg1);                     RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    34 #define PRINT2( txt, arg1, arg2 )                   \
       
    35     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2);                RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    36 #define PRINT3( txt, arg1, arg2, arg3 )             \
       
    37     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2,arg3);           RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    38 #define PRINT4( txt, arg1, arg2, arg3, arg4 )       \
       
    39     { TBuf<512> __buf; __buf.Format(txt, arg1,arg2,arg3,arg4);     RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    40 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
       
    41     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2,arg3,arg4,arg5); RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    42 
       
    43 #else
       
    44 
       
    45 #include <flogger.h>
       
    46 
       
    47 _LIT(KLogDirFullName, "c:\\logs\\");
       
    48 _LIT(KLogDir,         "Pcs");
       
    49 _LIT(KLogFile,        "PcsServer.txt");
       
    50 
       
    51 #define PRINT( txt )                                \
       
    52     RFileLogger::Write(KLogDir,KLogFile,EFileLoggingModeAppend,txt);
       
    53 #define PRINT1( txt, arg1 )                         \
       
    54     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1);
       
    55 #define PRINT2( txt, arg1, arg2 )                   \
       
    56     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2);
       
    57 #define PRINT3( txt, arg1, arg2, arg3 )             \
       
    58     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3);
       
    59 #define PRINT4( txt, arg1, arg2, arg3, arg4 )       \
       
    60     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4);
       
    61 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
       
    62     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4,arg5);
       
    63 
       
    64 #endif // __WINS__
       
    65 
       
    66 #else
       
    67 
       
    68 #define PRINT( txt )
       
    69 #define PRINT1( txt, arg1 )
       
    70 #define PRINT2( txt, arg1, arg2 )
       
    71 #define PRINT3( txt, arg1, arg2, arg3 )
       
    72 #define PRINT4( txt, arg1, arg2, arg3, arg4 )
       
    73 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 )
       
    74 
       
    75 #endif // _DEBUG
       
    76 
       
    77 #ifdef _DEBUG
       
    78 
       
    79 #define PRINTQUERY( txt, queryArg )         CPcsDebug::PrintQueryL(txt, queryArg);
       
    80 #define PRINTQUERYLIST( txt, queryListArg ) CPcsDebug::PrintQueryListL(txt, queryListArg);
       
    81 #define PRINTMATCHLOC( txt, matchLocsArg )  CPcsDebug::PrintMatchLoc(txt, matchLocsArg);
       
    82 #define PRINTMATCHSET( txt, matchSetArg )   CPcsDebug::PrintMatchSet(txt, matchSetArg);
       
    83 
       
    84 #else
       
    85 
       
    86 #define PRINTQUERY( txt, queryArg )
       
    87 #define PRINTQUERYLIST( txt, queryListArg )
       
    88 #define PRINTMATCHLOC( txt, matchLocsArg )
       
    89 #define PRINTMATCHSET( txt, matchSetArg )
       
    90 
       
    91 #endif // _DEBUG
       
    92 
       
    93 #define __LATENCY_MARK( str )     CPcsDebugWrapper::__LatencyMarkStartL(str);
       
    94 #define __LATENCY_MARKEND( str )  CPcsDebugWrapper::__LatencyMarkEnd(str);
       
    95 
       
    96 // Forward declarations
       
    97 class CPsQueryItem;
       
    98 class CPsQuery;
       
    99 class TPsMatchLocation;
       
   100 
       
   101 
       
   102 class CPcsDebug : public CBase
       
   103 {
       
   104 	public:
       
   105 	    IMPORT_C static CPcsDebug* NewL();
       
   106 	    IMPORT_C void Mark(TRefByValue<const TDesC> str,...);
       
   107 	    IMPORT_C void UnMark(TRefByValue<const TDesC> str,...);
       
   108 	    IMPORT_C static void PrintQueryL(const TDesC& aPreTxt, CPsQuery& aQuery);
       
   109 	    IMPORT_C static void PrintQueryListL(const TDesC& aPreTxt, RPointerArray<CPsQuery>& aPsQueryList);
       
   110         IMPORT_C static void PrintMatchLoc(const TDesC& aPreTxt, RArray<TPsMatchLocation>& aMatchLocs);
       
   111         IMPORT_C static void PrintMatchSet(const TDesC& aPreTxt, RPointerArray<TDesC>& aMatchSet);
       
   112         IMPORT_C static void PrintMatchSet(const TDesC& aPreTxt, CDesCArray& aMatchSet);
       
   113 	    
       
   114 	private:
       
   115 	    void ConstructL();
       
   116 	    
       
   117 	private:
       
   118 		TTime startTime;
       
   119 		TTime endTime;
       
   120 };
       
   121 
       
   122 
       
   123 class CPcsDebugArr : public CBase
       
   124 {
       
   125 	public:
       
   126 	    IMPORT_C static CPcsDebugArr* NewL();
       
   127 	    IMPORT_C void Push(CPcsDebug& dbg);
       
   128 	    IMPORT_C CPcsDebug* Pop();
       
   129 	    IMPORT_C TBool IsEmpty();
       
   130 	    
       
   131     public:
       
   132         ~CPcsDebugArr();
       
   133         	    
       
   134 	private:	    
       
   135 	    RPointerArray<CPcsDebug> debugArray;
       
   136 };
       
   137 
       
   138 class CPcsDebugWrapper : public CBase 
       
   139 {
       
   140 	public:
       
   141 	    IMPORT_C static void __LatencyMarkStartL(TRefByValue<const TDesC> str);
       
   142 	    IMPORT_C static void __LatencyMarkEnd(TRefByValue<const TDesC> str);
       
   143 };
       
   144 
       
   145 #endif // __PCS_DEBUG_H__
       
   146 
       
   147 // End of File