email/imum/logging/ImumLogContext.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006 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:  ImumLogContext.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef IMUMLOGCONTEXT_H
       
    20 #define IMUMLOGCONTEXT_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "ImumLogConfig.h"
       
    24 
       
    25 #ifdef _DEBUG
       
    26 
       
    27 // These macros are real macros, that should be used. For temporary purposes, these
       
    28 // are left out and the logging is done by simple entry logging
       
    29     #define _IMUM_UNCONTROLLED_INPUT_MSG  L"%s%d[%x:%x:%x]>%s UNCONTROLLED ENTRY!"
       
    30     #define _IMUM_MULTIPLE_ENTRY_MSG      L"%s%d[%x:%x:%x]%s  ADDITIONAL ENTRY!"
       
    31     #define _IMUM_UNCONTROLLER_EXIT_MSG   L"%s%d[%x:%x:%x]<%s UNCONTROLLED EXIT!"
       
    32     #define _IMUM_MULTIPLE_EXIT_MSG       L"%s%d[%x:%x:%x]%s  ADDITIONAL EXIT!"
       
    33 
       
    34     #define _IMUM_API_PREFIX              L"_A"
       
    35     #define _IMUM_LOCAL_PREFIX            L"_L"
       
    36 
       
    37     class _TImumContext
       
    38         {
       
    39         public:
       
    40             _TImumContext(
       
    41                 const TText* _fn,
       
    42                 const TUint _id,
       
    43                 const TUint _vis,
       
    44                 const TUint _addr,
       
    45                 const TUint _thdId,
       
    46                 const TText* _file,
       
    47                 const TUint _category=0 )
       
    48                 :
       
    49                 iFn(_fn),
       
    50                 iId(_id),
       
    51                 iApi((TBool)_vis),
       
    52                 iAddr(_addr),
       
    53                 iThdId(_thdId),
       
    54                 iVis((_vis == 0 ? (TText*)_IMUM_API_PREFIX : (TText*)_IMUM_LOCAL_PREFIX)),
       
    55                 iFile(_file),
       
    56                 iCategory(_category),
       
    57                 _dc( *this )
       
    58 
       
    59             #ifndef DISABLE_SYNTAX_CHECK
       
    60                 ,outOk(EFalse), inOk(EFalse)
       
    61             #endif
       
    62                 {
       
    63                 }
       
    64             ~_TImumContext()
       
    65                 {
       
    66                 #ifndef DISABLE_SYNTAX_CHECK
       
    67                     do
       
    68                         {
       
    69 //                        #ifndef DISABLE_GROUP_CHECKS
       
    70 //                                if ( (!TraceHeap::IsMaskOn(TRACENFO[iId].iGrpId)) || ((!iApi) && TraceHeap::IsApiOnly()) )
       
    71 //                                    {
       
    72 //                                    break;
       
    73 //                                    }
       
    74 //                        #endif
       
    75 
       
    76                         DoInChk();
       
    77                         if (!outOk)
       
    78                             {
       
    79                             _IMUMPRINTER(_IT(_IMUM_UNCONTROLLER_EXIT_MSG), iVis, iCategory, iId, iThdId, iAddr, iFn);
       
    80                             }
       
    81                         } while (0);
       
    82                 #endif // DISABLE_SYNTAX_CHECK
       
    83                 }
       
    84 
       
    85             const TText* iFn;
       
    86             const TUint iId;
       
    87             const TText* iVis;
       
    88             const TUint iAddr;
       
    89             const TInt iThdId;
       
    90             const TBool iApi;
       
    91             const TText* iFile;
       
    92             const TUint iCategory;
       
    93             _TImumContext& _dc;
       
    94 
       
    95             #ifndef DISABLE_SYNTAX_CHECK
       
    96                 inline void DoInChk()
       
    97                     {
       
    98                     if (!inOk)
       
    99                         {
       
   100                         _IMUMPRINTER(_IT(_IMUM_UNCONTROLLED_INPUT_MSG), iVis, iCategory, iId, iThdId, iAddr, iFn);
       
   101                         inOk = ETrue;
       
   102                         }
       
   103                     }
       
   104 
       
   105                 inline void ChkMultiIn()
       
   106                     {
       
   107                     if (inOk)
       
   108                         {
       
   109                         _IMUMPRINTER(_IT(_IMUM_MULTIPLE_ENTRY_MSG), iVis, iCategory, iId, iThdId, iAddr, iFn);
       
   110                         }
       
   111                     }
       
   112 
       
   113                 inline void ChkMultiOut()
       
   114                     {
       
   115                     if (outOk)
       
   116                         {
       
   117                         _IMUMPRINTER(_IT(_IMUM_MULTIPLE_EXIT_MSG), iVis, iCategory, iId, iThdId, iAddr, iFn);
       
   118                         }
       
   119                     }
       
   120 
       
   121                 TBool inOk;
       
   122                 TBool outOk;
       
   123             #endif // DISABLE_SYNTAX_CHECK
       
   124         };
       
   125 
       
   126 #endif // _DEBUG
       
   127 
       
   128 #endif      // IMUMLOGCONTEXT_H
       
   129 
       
   130 // End of File