apengine/apsettingshandlerui/inc/ApSettingsHandlerLogger.h
changeset 70 ac5daea24fb0
parent 0 5a93021fdf25
equal deleted inserted replaced
61:8b0c979bbe8c 70:ac5daea24fb0
       
     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 "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 *       Implemented logger functionality of the module
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef APSETTINGSHANDLER_LOGGER_H
       
    21 #define APSETTINGSHANDLER_LOGGER_H
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 
       
    27 #include <flogger.h>
       
    28 #include <eikenv.h>
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 const TInt KApSetUIMajorVersion = 4;
       
    34 const TInt KApSetUIMinorVersion = 0;
       
    35 const TInt KApSetUIBuildVersion = 16;
       
    36 
       
    37 _LIT( KApSetUILogMessageAppBanner,   "ApSetUI: (%d.%d.%d) started" );
       
    38 _LIT( KApSetUILogEnterFn,            "ApSetUI: -> %S" );
       
    39 _LIT( KApSetUILogLeaveFn,            "ApSetUI: <- %S" );
       
    40 _LIT( KApSetUILogExit,               "ApSetUI: exit" );
       
    41 _LIT( KApSetUILogTimeFormatString,   "%H:%T:%S:%*C3" );
       
    42 
       
    43 // NOTE! We're depending on FLogger DLL, because it assumes the existence
       
    44 // of C:\LOGS directory.
       
    45 _LIT( KApSetUIFLoggerDependency,        "c:\\logs\\" );
       
    46 _LIT( KApSetUIDoubleBackSlash,      "\\" );
       
    47 _LIT( KApSetUILogDir,                "data" );
       
    48 _LIT( KApSetUILogFile,               "apui.log" );
       
    49 
       
    50 
       
    51     enum TApSetUiLogMask                ///< Log mask bits.
       
    52         {
       
    53         ELogOff         = 0x00000000,   ///< Don't log.
       
    54         EDelete         = 0x00000001,   ///< Log delete activity.
       
    55         ESettings       = 0x00000002,   ///< Log Settings
       
    56         EListbox        = 0x00000004,   ///< Log listbox activity.
       
    57         EModel          = 0x00000008,   ///< Log Model activity.
       
    58         EAPI            = 0x00000010,   ///< Log API activity.
       
    59         EApImpl         = 0x00000020,   ///< Log Implementation activity.
       
    60         EDialog         = 0x00000040,   ///< Log dialog activity.
       
    61         EOther          = 0x00000080,   ///< Log other activity.
       
    62         /*
       
    63         EApItem         = 0x00000040,   ///< Log ApItem activity.
       
    64         ECommons        = 0x00000080,   ///< Log transaction activity.
       
    65         EActiveDb       = 0x000000F0,   ///< Log active db & notification 
       
    66                                         ///< activity.
       
    67         */
       
    68         ESpecial        = 0x0FFFF000,   ///< Log special, temp stuff only
       
    69         ELogAll         = 0xFFFFFFFF    ///< Log all.
       
    70         };
       
    71 
       
    72     // MACROS
       
    73 
       
    74     /// Determines what to log. Construct this from TApSetUiLogMask values.
       
    75 //    #define APSETUI_LOG_MASK ELogAll
       
    76 //    #define APSETUI_LOG_MASK    EDelete + EModel + EListbox
       
    77 //    #define APSETUI_LOG_MASK    EDelete + EModel
       
    78 // #define APSETUI_LOG_MASK ESettings +EListbox +EModel +EAPI +EApImpl +EDialog +EOther
       
    79     #define APSETUI_LOG_MASK    EModel
       
    80     
       
    81 
       
    82 #ifdef __TEST_LOGGING
       
    83     #define APSETUILOGGER_CREATE { \
       
    84                 TFileName path( KApSetUIFLoggerDependency );    \
       
    85                 path.Append( KApSetUILogDir );                  \
       
    86                 path.Append( KApSetUIDoubleBackSlash );         \
       
    87                 RFs& fs = CEikonEnv::Static()->FsSession();     \
       
    88                 fs.MkDirAll( path );                            \
       
    89                 RFileLogger::WriteFormat( KApSetUILogDir, KApSetUILogFile,  \
       
    90                                           EFileLoggingModeOverwrite,        \
       
    91                                           KApSetUILogMessageAppBanner,      \
       
    92                                           KApSetUIMajorVersion,             \
       
    93                                           KApSetUIMinorVersion,             \
       
    94                                           KApSetUIBuildVersion ); }         
       
    95     #define APSETUILOGGER_DELETE {                          \
       
    96                 RFileLogger::Write( KApSetUILogDir,         \
       
    97                                     KApSetUILogFile,        \
       
    98                                     EFileLoggingModeAppend, \
       
    99                                     KApSetUILogExit ); }
       
   100     #define APSETUILOGGER_ENTERFN( mask, a ) {                              \
       
   101                 _LIT( temp, a );                                            \
       
   102                 if (mask & APSETUI_LOG_MASK)                                \
       
   103                     {                                                       \
       
   104                     RFileLogger::WriteFormat( KApSetUILogDir,               \
       
   105                                               KApSetUILogFile,              \
       
   106                                               EFileLoggingModeAppend,       \
       
   107                                               KApSetUILogEnterFn, &temp );  \
       
   108                     } }
       
   109     #define APSETUILOGGER_LEAVEFN( mask, a ) {                              \
       
   110                 _LIT( temp, a );                                            \
       
   111                 if (mask & APSETUI_LOG_MASK)                                \
       
   112                     {                                                       \
       
   113                     RFileLogger::WriteFormat( KApSetUILogDir,               \
       
   114                                               KApSetUILogFile,              \
       
   115                                               EFileLoggingModeAppend,       \
       
   116                                               KApSetUILogLeaveFn, &temp );  \
       
   117                     } }
       
   118     #define APSETUILOGGER_WRITE( mask, a ) {                                \
       
   119                 _LIT( temp, a );                                            \
       
   120                 if (mask & APSETUI_LOG_MASK)                                \
       
   121                     {                                                       \
       
   122                     RFileLogger::Write( KApSetUILogDir,                     \
       
   123                                         KApSetUILogFile,                    \
       
   124                                     EFileLoggingModeAppend, temp );         \
       
   125                     } }
       
   126     #define APSETUILOGGER_WRITE_FORMAT( mask, a, b ) {                      \
       
   127                 _LIT( temp, a );                                            \
       
   128                 if (mask & APSETUI_LOG_MASK)                                \
       
   129                     {                                                       \
       
   130                     RFileLogger::WriteFormat( KApSetUILogDir,               \
       
   131                                               KApSetUILogFile,              \
       
   132                                               EFileLoggingModeAppend,       \
       
   133                                               temp, b );                    \
       
   134                     } }
       
   135     #define APSETUILOGGER_WRITE_TIMESTAMP( mask, a ) {                      \
       
   136                 _LIT( temp, a );                                            \
       
   137                 if (mask & APSETUI_LOG_MASK)                                \
       
   138                     {                                                       \
       
   139                     TTime time; TBuf<48> buf; time.HomeTime();              \
       
   140                     time.FormatL( buf, KApSetUILogTimeFormatString );       \
       
   141                     buf.Insert( 0, temp );                                  \
       
   142                     RFileLogger::Write( KApSetUILogDir, KApSetUILogFile,    \
       
   143                     EFileLoggingModeAppend, buf);                           \
       
   144                     } }
       
   145     #define APSETUILOGGER_WRITE_BUF( mask, a ) {                            \
       
   146                 if (mask & APSETUI_LOG_MASK)                                \
       
   147                     {                                                       \
       
   148                     RFileLogger::Write( KApSetUILogDir, KApSetUILogFile,    \
       
   149                                         EFileLoggingModeAppend, a);         \
       
   150                     } }
       
   151 #else
       
   152     #define APSETUILOGGER_CREATE {}
       
   153     #define APSETUILOGGER_DELETE {}
       
   154     #define APSETUILOGGER_ENTERFN( mask, a ) {}
       
   155     #define APSETUILOGGER_LEAVEFN( mask, a ) {}
       
   156     #define APSETUILOGGER_WRITE( mask, a ) {}
       
   157     #define APSETUILOGGER_WRITE_FORMAT( mask, a, b ) {}
       
   158     #define APSETUILOGGER_WRITE_TIMESTAMP( mask, a ) {}
       
   159     #define APSETUILOGGER_WRITE_BUF( mask, a ) {}
       
   160 #endif // __TEST_LOGGING
       
   161 
       
   162 #endif // APSETTINGSHANDLER_LOGGER_H
       
   163 
       
   164 // End of file