predictivesearch/PcsUtils/inc/CPcsDebug.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     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 //==============================================================================
       
    28 // winscw udeb
       
    29 //------------------------------------------------------------------------------
       
    30 
       
    31 #ifdef __WINS__
       
    32 #ifdef _DEBUG
       
    33 
       
    34 #define PRINT( txt )                                \
       
    35     { TBuf<512> __buf; __buf.Format(txt);                          RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    36 #define PRINT1( txt, arg1 )                         \
       
    37     { TBuf<512> __buf; __buf.Format(txt,arg1);                     RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    38 #define PRINT2( txt, arg1, arg2 )                   \
       
    39     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2);                RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    40 #define PRINT3( txt, arg1, arg2, arg3 )             \
       
    41     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2,arg3);           RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    42 #define PRINT4( txt, arg1, arg2, arg3, arg4 )       \
       
    43     { TBuf<512> __buf; __buf.Format(txt, arg1,arg2,arg3,arg4);     RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    44 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
       
    45     { TBuf<512> __buf; __buf.Format(txt,arg1,arg2,arg3,arg4,arg5); RDebug::Print( _L("[PCS] %S"), &__buf ); }
       
    46 #define PRINT_BOOT_PERFORMANCE( txt )
       
    47 #define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
       
    48 
       
    49 #endif // _DEBUG
       
    50 #endif // __WINS__
       
    51 
       
    52 //==============================================================================
       
    53 // armv5 udeb
       
    54 //------------------------------------------------------------------------------
       
    55 
       
    56 #ifndef __WINS__
       
    57 #ifdef _DEBUG
       
    58 
       
    59 #include <flogger.h>
       
    60 
       
    61 _LIT(KLogDirFullName, "c:\\logs\\");
       
    62 _LIT(KLogDir,         "Pcs");
       
    63 _LIT(KLogFile,        "PcsServer.txt");
       
    64 
       
    65 //#define __BOOT_PERFORMANCE
       
    66 #ifdef __BOOT_PERFORMANCE // Boot Peformance logs only
       
    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 #define PRINT_BOOT_PERFORMANCE( txt )                                \
       
    75     RFileLogger::Write(KLogDir,KLogFile,EFileLoggingModeAppend,txt);
       
    76 #define PRINT1_BOOT_PERFORMANCE( txt, arg1 )                         \
       
    77     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1);
       
    78 
       
    79 #else
       
    80 
       
    81 #define PRINT( txt )                                \
       
    82     RFileLogger::Write(KLogDir,KLogFile,EFileLoggingModeAppend,txt);
       
    83 #define PRINT1( txt, arg1 )                         \
       
    84     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1);
       
    85 #define PRINT2( txt, arg1, arg2 )                   \
       
    86     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2);
       
    87 #define PRINT3( txt, arg1, arg2, arg3 )             \
       
    88     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3);
       
    89 #define PRINT4( txt, arg1, arg2, arg3, arg4 )       \
       
    90     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4);
       
    91 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 ) \
       
    92     RFileLogger::WriteFormat(KLogDir,KLogFile,EFileLoggingModeAppend,TRefByValue<const TDesC>(txt),arg1,arg2,arg3,arg4,arg5);
       
    93 #define PRINT_BOOT_PERFORMANCE( txt )
       
    94 #define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
       
    95 
       
    96 #endif // __BOOT_PERFORMANCE
       
    97 
       
    98 #endif // __WINS__
       
    99 #endif // _DEBUG
       
   100 
       
   101 //==============================================================================
       
   102 // winscw urel AND armv5 urel
       
   103 //------------------------------------------------------------------------------
       
   104 
       
   105 #ifndef _DEBUG
       
   106 
       
   107 #define PRINT( txt )
       
   108 #define PRINT1( txt, arg1 )
       
   109 #define PRINT2( txt, arg1, arg2 )
       
   110 #define PRINT3( txt, arg1, arg2, arg3 )
       
   111 #define PRINT4( txt, arg1, arg2, arg3, arg4 )
       
   112 #define PRINT5( txt, arg1, arg2, arg3, arg4, arg5 )
       
   113 #define PRINT_BOOT_PERFORMANCE( txt )
       
   114 #define PRINT1_BOOT_PERFORMANCE( txt, arg1 )
       
   115 
       
   116 #endif // _DEBUG
       
   117 
       
   118 //==============================================================================
       
   119 
       
   120 
       
   121 #ifdef _DEBUG
       
   122 #define PRINTQUERY( txt, queryArg )         CPcsDebug::PrintQueryL(txt, queryArg);
       
   123 #define PRINTQUERYLIST( txt, queryListArg ) CPcsDebug::PrintQueryListL(txt, queryListArg);
       
   124 #define PRINTMATCHLOC( txt, matchLocsArg )  CPcsDebug::PrintMatchLoc(txt, matchLocsArg);
       
   125 #define PRINTMATCHSET( txt, matchSetArg )   CPcsDebug::PrintMatchSet(txt, matchSetArg);
       
   126 #else
       
   127 #define PRINTQUERY( txt, queryArg )
       
   128 #define PRINTQUERYLIST( txt, queryListArg )
       
   129 #define PRINTMATCHLOC( txt, matchLocsArg )
       
   130 #define PRINTMATCHSET( txt, matchSetArg )
       
   131 #endif // _DEBUG
       
   132 
       
   133 #define __LATENCY_MARK( str )     CPcsDebugWrapper::__LatencyMarkStartL(str);
       
   134 #define __LATENCY_MARKEND( str )  CPcsDebugWrapper::__LatencyMarkEnd(str);
       
   135 
       
   136 // Forward declarations
       
   137 class CPsQueryItem;
       
   138 class CPsQuery;
       
   139 class TPsMatchLocation;
       
   140 
       
   141 
       
   142 class CPcsDebug : public CBase
       
   143 {
       
   144 	public:
       
   145 	    IMPORT_C static CPcsDebug* NewL();
       
   146 	    IMPORT_C void Mark(TRefByValue<const TDesC> str,...);
       
   147 	    IMPORT_C void UnMark(TRefByValue<const TDesC> str,...);
       
   148 	    IMPORT_C static void PrintQueryL(const TDesC& aPreTxt, CPsQuery& aQuery);
       
   149 	    IMPORT_C static void PrintQueryListL(const TDesC& aPreTxt, RPointerArray<CPsQuery>& aPsQueryList);
       
   150         IMPORT_C static void PrintMatchLoc(const TDesC& aPreTxt, RArray<TPsMatchLocation>& aMatchLocs);
       
   151         IMPORT_C static void PrintMatchSet(const TDesC& aPreTxt, RPointerArray<TDesC>& aMatchSet);
       
   152         IMPORT_C static void PrintMatchSet(const TDesC& aPreTxt, CDesCArray& aMatchSet);
       
   153 	    
       
   154 	private:
       
   155 	    void ConstructL();
       
   156 	    
       
   157 	private:
       
   158 		TTime startTime;
       
   159 		TTime endTime;
       
   160 };
       
   161 
       
   162 
       
   163 class CPcsDebugArr : public CBase
       
   164 {
       
   165 	public:
       
   166 	    IMPORT_C static CPcsDebugArr* NewL();
       
   167 	    IMPORT_C void Push(CPcsDebug& dbg);
       
   168 	    IMPORT_C CPcsDebug* Pop();
       
   169 	    IMPORT_C TBool IsEmpty();
       
   170 	    
       
   171     public:
       
   172         ~CPcsDebugArr();
       
   173         	    
       
   174 	private:	    
       
   175 	    RPointerArray<CPcsDebug> debugArray;
       
   176 };
       
   177 
       
   178 class CPcsDebugWrapper : public CBase 
       
   179 {
       
   180 	public:
       
   181 	    IMPORT_C static void __LatencyMarkStartL(TRefByValue<const TDesC> str);
       
   182 	    IMPORT_C static void __LatencyMarkEnd(TRefByValue<const TDesC> str);
       
   183 };
       
   184 
       
   185 #endif // __PCS_DEBUG_H__
       
   186 
       
   187 // End of File