codhandler/ddrecog/inc/DdRecogLogger.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Logging macros for DD Recognizer.   
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef DD_RECOG_LOGGER_H
       
    22 #define DD_RECOG_LOGGER_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <e32def.h>
       
    28 #include <flogger.h>
       
    29 
       
    30 #ifdef _DEBUG
       
    31 
       
    32 /// DD logging directory.
       
    33 _LIT( KDdLogDir,                  "Dd" );
       
    34 /// DD log file name.
       
    35 _LIT( KDdLogFile,                  "DdRecog.txt" );
       
    36 /// Format string: enter function.
       
    37 _LIT( KDdLogEnterFn,               "-> %S" );
       
    38 /// Format string: leave function.
       
    39 _LIT( KDdLogLeaveFn,               "<- %S" );
       
    40 /// Format string: time.
       
    41 _LIT( KDdLogTimeFormatString,      "%H:%T:%S:%*C2" );
       
    42 /// Format string: timestamp.
       
    43 _LIT( KDdLogTimeStampFormatString, "%S %S" );
       
    44 
       
    45 /// Write log: enter function.
       
    46 #define CLOG_ENTERFN( a )           \
       
    47     {                               \
       
    48     _LIT( temp, a );                \
       
    49     RFileLogger::WriteFormat        \
       
    50         (                           \
       
    51         KDdLogDir,                 \
       
    52         KDdLogFile,                \
       
    53         EFileLoggingModeAppend,     \
       
    54         KDdLogEnterFn,             \
       
    55         &temp                       \
       
    56         );                          \
       
    57     }
       
    58 
       
    59 /// Write log: leave function.
       
    60 #define CLOG_LEAVEFN( a )           \
       
    61     {                               \
       
    62     _LIT( temp, a );                \
       
    63     RFileLogger::WriteFormat        \
       
    64         (                           \
       
    65         KDdLogDir,                 \
       
    66         KDdLogFile,                \
       
    67         EFileLoggingModeAppend,     \
       
    68         KDdLogLeaveFn,             \
       
    69         &temp                       \
       
    70         );                          \
       
    71     }
       
    72 
       
    73 /// Write log: string 'a'.
       
    74 #define CLOG_WRITE( a )             \
       
    75     {                               \
       
    76     _LIT( temp, a );                \
       
    77     RFileLogger::Write              \
       
    78         (                           \
       
    79         KDdLogDir,                 \
       
    80         KDdLogFile,                \
       
    81         EFileLoggingModeAppend,     \
       
    82         temp                        \
       
    83         );                          \
       
    84     }
       
    85 
       
    86 /// Write log: formatted.
       
    87 #define CLOG_WRITE_FORMAT( a, b )   \
       
    88     {                               \
       
    89     _LIT( temp, a );                \
       
    90     RFileLogger::WriteFormat        \
       
    91         (                           \
       
    92         KDdLogDir,                 \
       
    93         KDdLogFile,                \
       
    94         EFileLoggingModeAppend,     \
       
    95         temp,                       \
       
    96         b                           \
       
    97         );                          \
       
    98     }
       
    99 
       
   100 /// Write log: timestamp.
       
   101 #define CLOG_WRITE_TIMESTAMP( a )                                   \
       
   102     {                                                               \
       
   103     _LIT( temp, a );                                                \
       
   104     TTime time;                                                     \
       
   105     time.HomeTime();                                                \
       
   106     TBuf<32> timeBuf;                                               \
       
   107     TRAPD( err, time.FormatL( timeBuf, KDdLogTimeFormatString ) ); \
       
   108     if ( !err )                                                     \
       
   109         {                                                           \
       
   110         RFileLogger::WriteFormat                                    \
       
   111             (                                                       \
       
   112             KDdLogDir,                                             \
       
   113             KDdLogFile,                                            \
       
   114             EFileLoggingModeAppend,                                 \
       
   115             KDdLogTimeStampFormatString,                           \
       
   116             &temp,                                                  \
       
   117             &timeBuf                                                \
       
   118             );                                                      \
       
   119         }                                                           \
       
   120     }
       
   121 
       
   122 #else /* not defined _DEBUG */
       
   123 
       
   124 /// Empty definition (disable log).
       
   125 #define CLOG_ENTERFN( a )
       
   126 
       
   127 /// Empty definition (disable log).
       
   128 #define CLOG_LEAVEFN( a )
       
   129 
       
   130 /// Empty definition (disable log).
       
   131 #define CLOG_WRITE( a )
       
   132 
       
   133 /// Empty definition (disable log).
       
   134 #define CLOG_WRITE_FORMAT( a, b )
       
   135 
       
   136 /// Empty definition (disable log).
       
   137 #define CLOG_WRITE_TIMESTAMP( a )
       
   138 
       
   139 #endif /* def _DEBUG */
       
   140 
       
   141 #endif /* def DD_RECOG_LOGGER_H */