phonebookui/Phonebook2/ccapplication/inc/ccalogger.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 85 38bb213f60ba
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:  This is class is for logging purposes.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef _CCALOGGER_H
       
    20 #define _CCALOGGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 // logging is done only in debug
       
    25 #ifdef _DEBUG
       
    26 #include <flogger.h>
       
    27 #include <e32debug.h>
       
    28 
       
    29 //Logging constants
       
    30 _LIT(KLogDir, "cca");
       
    31 
       
    32 #define CCA_L(s) _L(s)
       
    33 #define CCA_L8(s) _L8(s)
       
    34 
       
    35 #define CCA_DP CCADebugWriteFormat
       
    36 
       
    37 
       
    38 /**
       
    39 * Log file printing utility function
       
    40 * @since Series 60 v5.0
       
    41 */
       
    42 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC> aFmt,...) //lint !e960
       
    43     {
       
    44 
       
    45     TBuf< 256 > buffer;
       
    46 
       
    47         {
       
    48         VA_LIST list;
       
    49         VA_START (list, aFmt); //lint !e960
       
    50         TBuf< 300 > formatted;
       
    51         formatted.FormatList( aFmt, list );
       
    52         buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); 
       
    53         }
       
    54     
       
    55     RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer );
       
    56     RDebug::RawPrint(buffer);
       
    57   
       
    58     }
       
    59 
       
    60 /**
       
    61 * Log file printing utility function
       
    62 * @since Series 60 v5.0
       
    63 */
       
    64 
       
    65 inline void CCADebugWriteFormat( TRefByValue<const TDesC> aFile, TRefByValue<const TDesC8> aFmt,...) //lint !e960
       
    66     {
       
    67     TBuf8< 256 > buffer;
       
    68         {
       
    69         VA_LIST list;
       
    70         VA_START (list, aFmt); //lint !e960
       
    71         TBuf8< 300 > formatted;
       
    72         formatted.FormatList( aFmt, list );
       
    73         buffer.Append( formatted.Left( buffer.MaxLength() - buffer.Length() ) ); 
       
    74         }    
       
    75     RFileLogger::Write( KLogDir, aFile, EFileLoggingModeAppend, buffer );
       
    76     RDebug::RawPrint(buffer);
       
    77     }
       
    78 
       
    79 
       
    80 #else // _DEBUG
       
    81 
       
    82 struct TCCAEmptyDebugString { };
       
    83 
       
    84 #define CCA_L(s) TCCAEmptyDebugString()
       
    85 #define CCA_L8(s) TCCAEmptyDebugString()
       
    86 
       
    87 /// Empty debug print function for release builds.
       
    88 inline void CCA_DP(TCCAEmptyDebugString)
       
    89     {
       
    90     }
       
    91 
       
    92 template<class T1>
       
    93 inline void CCA_DP(TCCAEmptyDebugString,T1)
       
    94     {
       
    95     }
       
    96 
       
    97 template<class T1,class T2>
       
    98 inline void CCA_DP(TCCAEmptyDebugString,T1,T2)
       
    99     {
       
   100     }
       
   101 
       
   102 template<class T1,class T2,class T3>
       
   103 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3)
       
   104     {
       
   105     }
       
   106 
       
   107 template<class T1,class T2,class T3,class T4>
       
   108 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4)
       
   109     {
       
   110     }
       
   111 
       
   112 template<class T1,class T2,class T3,class T4,class T5>
       
   113 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5)
       
   114     {
       
   115     }
       
   116 
       
   117 template<class T1,class T2,class T3,class T4,class T5,class T6>
       
   118 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6)
       
   119     {
       
   120     }
       
   121 
       
   122 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7>
       
   123 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7)
       
   124     {
       
   125     }
       
   126 
       
   127 template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
       
   128 inline void CCA_DP(TCCAEmptyDebugString,T1,T2,T3,T4,T5,T6,T7,T8)
       
   129     {
       
   130     }
       
   131 
       
   132 #endif // _DEBUG
       
   133 
       
   134 
       
   135 /**
       
   136  * PERFORMANCE LOGGINS
       
   137  * Logging is down only in debug, to get the log files,
       
   138  * need to enable the _DEBUG marco first.
       
   139  *   
       
   140  * OPTIONS: 
       
   141  * PERF_LOGGING -> 12 different points where performance is measured. (c:\logs\perflogger.txt) 
       
   142  *                 http://presenceprojects/trac/wiki/PerfLogging
       
   143  * PERF_LAUNCH -> For test guys (c:\logs\perflaunch.txt)
       
   144  * 
       
   145  */
       
   146 
       
   147 #ifdef _DEBUG   
       
   148 #define PERF_LOGGING
       
   149 #define PERF_LAUNCH 
       
   150 #endif //_DEBUG
       
   151 
       
   152 
       
   153 #ifdef PERF_LOGGING
       
   154 #include <flogger.h>
       
   155 
       
   156 _LIT( KPerfLogDir,                           "cca" );
       
   157 _LIT( KPerfLogFile,                          "perflogger.txt" );
       
   158 
       
   159 #define CCA_PERF WriteToPerfLog
       
   160 
       
   161 inline void WriteToPerfLog(  )
       
   162     {
       
   163     TBuf<30> dateString;
       
   164     TTime time;
       
   165     time.HomeTime();
       
   166     _LIT(KDateString,"%-B%:0%J%:1%T%:2%S%.%*C4");    
       
   167     time.FormatL(dateString,KDateString);
       
   168     
       
   169     RFileLogger::Write( KPerfLogDir, KPerfLogFile, EFileLoggingModeAppend, dateString );  
       
   170     }
       
   171 
       
   172 #else // PERF_LOGGING
       
   173 
       
   174 inline void WriteToPerfLog(  )
       
   175     {
       
   176     }
       
   177 
       
   178 #endif // PERF_LOGGING
       
   179 
       
   180 
       
   181 
       
   182 
       
   183 #ifdef PERF_LAUNCH
       
   184 #include <flogger.h>
       
   185 
       
   186 _LIT( KPerfLaunchLogDir,                           "cca" );
       
   187 _LIT( KPerfLaunchLogFile,                          "perflaunch.txt" );
       
   188 _LIT( KPerfLaunchLogTimeFormatString,   "%T:%S:%*C4" );
       
   189 
       
   190 inline void WriteToPerfLaunchLog( const TDesC& aText )
       
   191     {
       
   192     TBuf<30> dateString;
       
   193     TTime time;
       
   194     time.HomeTime();    
       
   195     time.FormatL(dateString,KPerfLaunchLogTimeFormatString);
       
   196     dateString.Append(aText);
       
   197     RFileLogger::Write( KPerfLaunchLogDir, KPerfLaunchLogFile, EFileLoggingModeAppend, dateString );  
       
   198     }
       
   199 
       
   200 
       
   201 #else // PERF_LAUNCH
       
   202 
       
   203 inline void WriteToPerfLaunchLog( const TDesC& /*aText*/ )
       
   204     {
       
   205     }
       
   206 
       
   207 
       
   208 #endif // PERF_LAUNCH
       
   209 
       
   210 
       
   211 
       
   212 
       
   213 
       
   214 
       
   215 
       
   216 #endif // _CCALOGGER_H
       
   217             
       
   218 // End of File