emailservices/emaildebug/inc/emailtrace.h
branchRCL_3
changeset 25 3533d4323edc
parent 24 d189ee25cf9d
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
     1 /*
     1 /*
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     3  * All rights reserved.
     3 * All rights reserved.
     4  * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8  *
     8 *
     9  * Initial Contributors:
     9 * Initial Contributors:
    10  * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11  *
    11 *
    12  * Contributors:
    12 * Contributors:
    13  *
    13 *
    14  * Description:
    14 * Description:  Header file describing trace utilities for commonemail
    15  *
    15 *
    16  */
    16 */
    17 
    17 
    18 #ifndef EMAILTRACE_H
    18 #ifndef EMAILTRACE_H
    19 #define EMAILTRACE_H
    19 #define EMAILTRACE_H
    20 
    20 
    21 #include <QCoreApplication>
    21 #include "emailtraceconfig.hrh"
    22 #include <QDebug>
    22 
    23 #include <QFile>
    23 #ifdef TRACE_INTO_FILE
    24 #include <QThread>
    24 #include "cmaillogger.h"
    25 #include <QDateTime>
    25 #include <flogger.h> // RFileLogger
    26 
    26 #else
    27 /*
    27 #include <e32debug.h> // RDebug
    28  * The macros NM_COMMENT_TRACES, NM_ERROR_TRACES, and NM_FUNCTION_TRACES
       
    29  * control which debug messages are printed. The trace logging is controlled
       
    30  * with the NM_LOG_TO_FILE macro, whereas the NM_LOG_DIRECTORY macro defines
       
    31  * which directory is to be used to store the log files. The print_trace()
       
    32  * helper function implements printing. Log files are named according to
       
    33  * process and thread IDs. If NM_LOG_TO_FILE is zero or a log file cannot be
       
    34  * opened, the messages are printed to qDebug(). The DSC2STR() function can
       
    35  * be used to convert Symbian descriptors to QString objects.
       
    36  */
       
    37 #if defined(DEBUG) || defined(_DEBUG) || NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
       
    38 
       
    39 #ifndef NM_COMMENT_TRACES
       
    40 #define NM_COMMENT_TRACES  0
       
    41 #endif
    28 #endif
    42 
    29 
    43 #ifndef NM_ERROR_TRACES
    30 /**
    44 #define NM_ERROR_TRACES    0
    31 * Constants
       
    32 */
       
    33 #if defined(TRACE_INTO_FILE)
       
    34 
       
    35     _LIT(  KEmailDir, "email" );
       
    36     _LIT(  KEmailTraceFile, "email.txt" );
       
    37 
    45 #endif
    38 #endif
    46 
    39 
    47 #ifndef NM_FUNCTION_TRACES
    40 #if defined(TRACE_FILE_LIMIT_SIZE)
    48 #define NM_FUNCTION_TRACES 0
    41     #define CMAIL_LOG_CLOSE CmailLogger::Close();
       
    42     #define CMAILLOGBUFFERSIZE 120
       
    43 #else
       
    44     #define CMAIL_LOG_CLOSE 
    49 #endif
    45 #endif
    50 
    46 
    51 #if NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
    47 //-----------------------------------------------------------------------------
    52 
    48 // Error trace macros
    53 #define NM_LOG_TO_FILE   1
    49 //-----------------------------------------------------------------------------
    54 #define NM_LOG_DIRECTORY "c:/data/logs/"
    50 //
    55 
    51 
    56 inline void print_trace(const QString& msg)
    52 #ifdef ERROR_TRACE
    57 {
    53 
    58     static QFile file(NM_LOG_DIRECTORY+
    54     /**
    59                       QString("nmail_p%1_t%2.log").
    55     * Error trace definitions. Does not automatically log the error code!
    60                       arg(QCoreApplication::applicationPid()).
    56     */    
    61                       arg(QThread::currentThreadId()));
    57     #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
    62     if (NM_LOG_TO_FILE && !file.isOpen()) {
    58 
    63         file.open(QIODevice::Append | QIODevice::Text);
    59         #define ERROR( aErr, aMsg )\
    64     }
    60             {\
    65     QDateTime dt = QDateTime::currentDateTime ();
    61             if( aErr != KErrNone )\
    66     if (file.isWritable()) {
    62                 {\
    67         QDebug(&file).nospace() << dt.toString(Qt::ISODate) << " " << msg << '\n';
    63                 _LIT( KMsg, aMsg );\
    68     } else {
    64                 RFileLogger::Write(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg );\
    69         qDebug().nospace() << "[Nmail] " << msg;
    65                 }\
    70     }
    66             }
    71 }
    67         #define ERROR_1( aErr, aMsg, aP1 )\
    72 
    68             {\
    73 #endif
    69             if( aErr != KErrNone )\
    74 
    70                 {\
    75 inline QString DSC2STR(const TDesC& dsc)
    71                 _LIT( KMsg, aMsg );\
    76 {
    72                 RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
    77     return QString::fromRawData(reinterpret_cast<const QChar*>(dsc.Ptr()),
    73                 }\
    78                                 dsc.Length());
    74             }
    79 }
    75         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
    80 
    76             {\
    81 #else
    77             if( aErr != KErrNone )\
    82 
    78                 {\
    83 #define DSC2STR(dsc)
    79                 _LIT( KMsg, aMsg );\
    84 
    80                 RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2 );\
    85 #endif /* DEBUG */
    81                 }\
    86 
    82             }
    87 /*
    83         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
    88  * The function NM_COMMENT() prints a debug message. The INFO macros and the
    84             {\
    89  * NMLOG macro are provided for legacy compatibility. They are deprecated and
    85             if( aErr != KErrNone )\
    90  * should not be used. If sprintf() type of formatting is desired, consider
    86                 {\
    91  * using QString::arg() or QTextStream.
    87                 _LIT( KMsg, aMsg );\
    92  */
    88                 RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\
    93 #if NM_COMMENT_TRACES
    89                 }\
    94 
    90             }
    95 inline void NM_COMMENT(const QString& msg)
    91         #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
    96 {
    92         #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
    97     print_trace("COMMENT : " + msg);
    93     #endif
    98 }
    94     #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE)
    99 #define INFO(msg) NM_COMMENT(msg)
    95     
   100 #define INFO_1(msg,arg1)\
    96         #define ERROR( aErr, aMsg )\
   101 do {\
    97         {\
   102     QString __msg;\
    98             if( aErr != KErrNone )\
   103     __msg.sprintf(msg,arg1);\
    99             {\
   104     NM_COMMENT(__msg);\
   100             _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KMsg(); if ( KMsg().Size() < buf.MaxSize() ) { CmailLogger::Write( buf ); }}\
   105 } while (0)
   101         }    
   106 #define INFO_2(msg,arg1,arg2)\
   102     
   107 do {\
   103     #define ERROR_1( aErr, aMsg, aP1 )\
   108     QString __msg;\
   104         {\
   109     __msg.sprintf(msg,arg1,arg2);\
   105             if( aErr != KErrNone )\
   110     NM_COMMENT(__msg);\
   106             {\
   111 } while (0)
   107             _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); CmailLogger::Write( buf ); } }\
   112 #define INFO_3(msg,arg1,arg2,arg3)\
   108         }    
   113 do {\
   109         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
   114     QString __msg;\
   110         {\
   115     __msg.sprintf(msg,arg1,arg2,arg3);\
   111             if( aErr != KErrNone )\
   116     NM_COMMENT(__msg);\
   112             {\
   117 } while (0)
   113             _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1, aP2 ); CmailLogger::Write( buf ); }} \
   118 #define NMLOG(msg) NM_COMMENT(msg)
   114         }    
   119 
   115         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
   120 #else
   116         {\
   121 
   117             if( aErr != KErrNone )\
   122 #define NM_COMMENT(msg)
   118             {\
   123 #define INFO(msg)
   119             _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1, aP2, aP3 ); CmailLogger::Write( buf ); }}\
   124 #define INFO_1(msg,arg1)
   120         }        
   125 #define INFO_2(msg,arg1,arg2)
   121     #endif
   126 #define INFO_3(msg,arg1,arg2,arg3)
   122     #if !defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
   127 #define NMLOG(msg)
   123 
   128 
   124         #define ERROR( aErr, aMsg )\
   129 #endif /* NM_COMMENT_TRACES */
   125             {\
   130 
   126             if( aErr != KErrNone )\
   131 /*
   127                 {\
   132  * The function NM_ERROR() prints its second argument if the first argument
   128                 _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\
   133  * is non-zero. The ERROR macros are provided for legacy compatibility. They
   129                 }\
   134  * are deprecated and should not be used. If sprintf() type of formatting is
   130             }
   135  * desired, consider using QString::arg() or QTextStream.
   131         #define ERROR_1( aErr, aMsg, aP1 )\
   136  */
   132             {\
   137 #if NM_ERROR_TRACES
   133             if( aErr != KErrNone )\
   138 
   134                 {\
   139 inline void NM_ERROR(int err, const QString& msg)
   135                 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\
   140 {
   136                 }\
   141     if (err) {
   137             }
   142         print_trace("ERROR : " + msg);
   138         #define ERROR_2( aErr, aMsg, aP1, aP2 )\
   143     }
   139             {\
   144 }
   140             if( aErr != KErrNone )\
   145 #define ERROR(err,msg) NM_ERROR(err,msg)
   141                 {\
   146 #define ERROR_1(err,msg,arg1)\
   142                 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\
   147 do {\
   143                 }\
   148     QString __msg;\
   144             }
   149     __msg.sprintf(msg,arg1);\
   145         #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\
   150     NM_ERROR(err,__msg);\
   146             {\
   151 } while (0)
   147             if( aErr != KErrNone )\
   152 #define ERROR_2(err,msg,arg1,arg2)\
   148                 {\
   153 do {\
   149                 _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\
   154     QString __msg;\
   150                 }\
   155     __msg.sprintf(msg,arg1,arg2);\
   151             }
   156     NM_ERROR(err,__msg);\
   152         #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg )
   157 } while(0)
   153         #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 )
   158 #define ERROR_3(err,msg,arg1,arg2,arg3)\
   154 
   159 do {\
   155     #endif//TRACE_INTO_FILE
   160     QString __msg;\
   156 
   161     __msg.sprintf(msg,arg1,arg2,arg3);\
   157 #else//ERROR_TRACE not defined
   162     NM_ERROR(err,__msg);\
   158 
   163 } while(0)
   159     #define ERROR( aErr, aMsg )
   164 #define ERROR_GEN(msg) ERROR(KErrGeneral,msg)
   160     #define ERROR_1( aErr, aMsg, aP1 )
   165 #define ERROR_GEN_1(msg,arg1) ERROR_1(KErrGeneral,msg,arg1)
   161     #define ERROR_2( aErr, aMsg, aP1, aP2 )
   166 
   162     #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )
   167 #else
   163     #define ERROR_GEN( aMsg )
   168 
   164     #define ERROR_GEN_1( aMsg, aP1 )
   169 #define NM_ERROR(err,msg)
   165 
   170 #define ERROR(err,msg)
   166 #endif//ERROR_TRACE
   171 #define ERROR_1(err,msg,arg1)
   167 
   172 #define ERROR_2(err,msg,arg1,arg2)
   168 
   173 #define ERROR_3(err,msg,arg1,arg2,arg3)
   169 //-----------------------------------------------------------------------------
   174 #define ERROR_GEN(msg)
   170 // Info trace macros
   175 #define ERROR_GEN_1(msg,arg1)
   171 //-----------------------------------------------------------------------------
   176 
   172 //
   177 #endif /* NM_ERROR_TRACES */
   173 #if defined(INFO_TRACE)
   178 
   174 
   179 /*
   175     /**
   180  * The macro NM_FUNCTION, when used inside a function body, enables tracing
   176     * Info log message definitions.
   181  * for a function. If used, it should be placed on the first line of the
   177     */
   182  * function body. ENTER and RETURN messages are printed when entering into
   178     #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
   183  * and returning from a function, respectively. In case of an exception,
   179 
   184  * UNWIND (for stack unwinding) is printed instead of RETURN. The FUNC_LOG
   180         #define INFO( aMsg )\
   185  * macro is provided for legacy compatibility. It is deprecated and should
   181             {\
   186  * not be used.
   182             _LIT( KMsg, aMsg );\
   187  */
   183             RFileLogger::Write(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg );\
   188 #if NM_FUNCTION_TRACES
   184             }
   189 
   185         #define INFO_1( aMsg, aP1 )\
   190 class __ftracer
   186             {\
   191 {
   187             _LIT( KMsg, aMsg );\
   192 public:
   188             RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
   193     __ftracer(const QString& _fn)
   189             }
   194     : fn(_fn)
   190         #define INFO_2( aMsg, aP1, aP2 )\
   195     {
   191             {\
   196         print_trace("ENTER : " + fn);
   192             _LIT( KMsg, aMsg );\
   197     }
   193             RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2 );\
   198     ~__ftracer()
   194             }
   199     {
   195         #define INFO_3( aMsg, aP1, aP2, aP3 )\
   200         if (std::uncaught_exception()) {
   196             {\
   201             print_trace("UNWIND : " + fn);
   197             _LIT( KMsg, aMsg );\
   202         } else {
   198             RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1, aP2, aP3 );\
   203             print_trace("RETURN : " + fn);
   199             }
   204         }
   200     #endif // // TRACE_INTO_FILE && TRACE_FILE_LIMIT_SIZE
   205     }
   201     
   206 private:
   202     #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE)
   207     QString fn;
   203         #define CMAIL_LOG_INIT
   208 };
   204         
   209 
   205         #define INFO( aMsg )\
   210 #define NM_FUNCTION __ftracer __ft(__PRETTY_FUNCTION__)
   206             {\
   211 #define FUNC_LOG NM_FUNCTION
   207             _LIT8( KMsg, aMsg );\
   212 
   208             CmailLogger::Write( KMsg );\
   213 #else
   209             }
   214 
   210         #define INFO_1( aMsg, aP1 )\
   215 #define NM_FUNCTION
   211             { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\
   216 #define FUNC_LOG
   212              if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); }\
   217 
   213                 CmailLogger::Write( buf ); }
   218 #endif /* NM_FUNCTION_TRACES */
   214         #define INFO_2( aMsg, aP1, aP2 )\
   219 
   215             { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\
   220 #endif /* EMAILTRACE_H */
   216              if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1,aP2 ); }\
       
   217                 CmailLogger::Write( buf ); }
       
   218         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   219             { _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8();\
       
   220              if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1,aP2,aP3 ); }\
       
   221                 CmailLogger::Write( buf ); }
       
   222     #endif // TRACE_INTO_FILE && TRACE_FILE_LIMIT_SIZE
       
   223     #if !defined(TRACE_INTO_FILE)
       
   224 
       
   225         #define INFO( aMsg )\
       
   226             {\
       
   227             _LIT( KMsg, aMsg ); RDebug::Print( KMsg );\
       
   228             }
       
   229         #define INFO_1( aMsg, aP1 )\
       
   230             {\
       
   231             _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1 );\
       
   232             }
       
   233         #define INFO_2( aMsg, aP1, aP2 )\
       
   234             {\
       
   235             _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2 );\
       
   236             }
       
   237         #define INFO_3( aMsg, aP1, aP2, aP3 )\
       
   238             {\
       
   239             _LIT( KMsg, aMsg ); RDebug::Print( KMsg, aP1, aP2, aP3 );\
       
   240             }
       
   241 
       
   242     #endif//TRACE_INTO_FILE
       
   243                            
       
   244 #else//INFO_TRACE not defined
       
   245     
       
   246     #define CMAIL_LOG_INIT
       
   247     #define CMAIL_LOG_CLOSE
       
   248     #define INFO( aMsg )
       
   249     #define INFO_1( aMsg, aP1 )
       
   250     #define INFO_2( aMsg, aP1, aP2 )
       
   251     #define INFO_3( aMsg, aP1, aP2, aP3 )
       
   252 
       
   253 #endif//INFO_TRACE
       
   254 
       
   255 //-----------------------------------------------------------------------------
       
   256 // Function trace macros
       
   257 //-----------------------------------------------------------------------------
       
   258 //
       
   259  
       
   260 #if defined (FUNC_TRACE)
       
   261 
       
   262     // Constants
       
   263     _LIT8( KEllipse, "(" );
       
   264 
       
   265     //
       
   266     // Function logging definitions.
       
   267     //
       
   268     
       
   269     
       
   270     #if defined(TRACE_FILE_LIMIT_SIZE)
       
   271         #define FUNC( aMsg, aP1 )\
       
   272         {\
       
   273             _LIT8( KMsg, aMsg );TBuf8<CMAILLOGBUFFERSIZE> buf=KNullDesC8(); if ( KMsg().Size() < buf.MaxSize() ) { buf.Format( KMsg, aP1 ); }CmailLogger::Write( buf ); }
       
   274     #endif
       
   275     #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
       
   276         #define FUNC( aMsg, aP1 )\
       
   277             {\
       
   278             _LIT8( KMsg, aMsg ); RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KMsg, aP1 );\
       
   279             }
       
   280     #endif
       
   281     #if !defined(TRACE_INTO_FILE) 
       
   282         #define FUNC( aMsg, aP1 )\
       
   283             {\
       
   284             RDebug::Printf( aMsg, aP1 );\
       
   285             }\
       
   286 
       
   287     #endif//TRACE_INTO_FILE
       
   288     
       
   289     /**
       
   290     * Function trace helper class.
       
   291     */
       
   292     class TFuncLog
       
   293         {
       
   294         public:
       
   295             inline TFuncLog( const char* aFunc ): iFunc( (TUint8*)aFunc )
       
   296                 {
       
   297                 TInt pos = iFunc.Find( KEllipse );
       
   298                 if( pos != KErrNotFound )
       
   299                     {
       
   300                     iFunc.Set( iFunc.Left( iFunc.Find( KEllipse ) ) );
       
   301                     }
       
   302                 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
       
   303 
       
   304                     //"CMAIL" string is added in the beginning of every trace
       
   305                     //line for filtering purposes
       
   306                     FUNC( "CMAIL %S <", &iFunc );
       
   307                 #endif
       
   308                 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE)
       
   309                     TBuf8<CMAILLOGBUFFERSIZE> buf(iFunc);
       
   310                     buf.Append(_L("<"));
       
   311                     CmailLogger::Write( buf );
       
   312                 #endif
       
   313                 #if !defined(TRACE_INTO_FILE)
       
   314 
       
   315                     FUNC( "CMAIL %s <", iFunc.Ptr() );
       
   316 
       
   317                 #endif//TRACE_INTO_FILE
       
   318                 }
       
   319             inline ~TFuncLog()
       
   320                 {
       
   321                 #if defined(TRACE_INTO_FILE) && !defined(TRACE_FILE_LIMIT_SIZE)
       
   322                     FUNC( "CMAIL %S >", &iFunc );
       
   323                 #endif
       
   324                 #if defined(TRACE_INTO_FILE) && defined(TRACE_FILE_LIMIT_SIZE)
       
   325                     TBuf8<CMAILLOGBUFFERSIZE> buf(iFunc);
       
   326                     buf.Append(_L(">"));
       
   327                     CmailLogger::Write( buf );
       
   328                 #endif
       
   329                 #if !defined(TRACE_INTO_FILE)
       
   330 
       
   331                     FUNC( "CMAIL %s >", iFunc.Ptr() );
       
   332                 #endif//TRACE_INTO_FILE
       
   333                 }
       
   334             TPtrC8 iFunc;
       
   335         };
       
   336 
       
   337     #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ );
       
   338 #else//FUNC_TRACE not defined
       
   339 
       
   340     #define FUNC_LOG
       
   341 
       
   342 #endif//FUNC_TRACE
       
   343 
       
   344 //-----------------------------------------------------------------------------
       
   345 // Timestamp trace macros
       
   346 //-----------------------------------------------------------------------------
       
   347 //
       
   348 #if defined(TIMESTAMP_TRAC)
       
   349 
       
   350     #if defined(TRACE_INTO_FILE)
       
   351 
       
   352         #define TIMESTAMP( aCaption )\
       
   353             {\
       
   354             TTime t;\
       
   355             t.HomeTime();\
       
   356             TDateTime dt = t.DateTime();\
       
   357             _LIT( KMsg, aCaption );\
       
   358             _LIT( KFormat, "[TIMESTAMP] %d:%02d:%02d.%06d us %S");\
       
   359             RFileLogger::WriteFormat(  KEmailDir,  KEmailTraceFile, EFileLoggingModeAppend, KFormat,\
       
   360                 dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(), &KMsg );\
       
   361             }
       
   362 
       
   363     #else//TRACE_INTO_FILE not defined
       
   364 
       
   365         #define TIMESTAMP( aCaption )\
       
   366             {\
       
   367             TTime t;\
       
   368             t.HomeTime();\
       
   369             TDateTime dt = t.DateTime();\
       
   370             _LIT( KMsg, aCaption );\
       
   371             _LIT( KFormat, "[TIMESTAMP] %d:%02d:%02d.%06d us %S");\
       
   372             RDebug::Print( KFormat,\
       
   373                 dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(), &KMsg );\
       
   374             }
       
   375 
       
   376     #endif//TRACE_INTO_FILE
       
   377 
       
   378 #else//TIMESTAMP_TRACE not defined
       
   379 
       
   380     #define TIMESTAMP( aCaption )
       
   381 
       
   382 #endif//TIMESTAMP_TRACE
       
   383 
       
   384 #endif // EMAILTRACE_H