imstutils/imconnectionprovider/inc/icplogger.h
branchRCL_3
changeset 29 9a48e301e94b
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Provides macros for logging
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __ICPLOGGER_H__
       
    21 #define __ICPLOGGER_H__
       
    22 
       
    23 #ifdef __WINS__
       
    24  #ifdef _DEBUG
       
    25     #define ICP_ENABLE_DEBUG_LOGS // for WINS UDEB
       
    26  #endif
       
    27 #else
       
    28  #ifdef _DEBUG     
       
    29     #define ICP_ENABLE_DEBUG_LOGS // for device UDEB
       
    30  #endif
       
    31 #endif
       
    32 #define SCP_TP_PRINT(s) L##s
       
    33 #define SCP_STRA_PRINT(s) SCP_TP_PRINT(s)
       
    34 #define SCP_STR_PRINT(t) SCP_STRA_PRINT("[SCP]") L##t
       
    35 #define SCP_LIT_PRINT(s) TPtrC((const TText *) SCP_STR_PRINT(s))
       
    36 #define SCP_LIT_CONVERT(s) TPtrC((const TText *)(s))
       
    37 
       
    38 //-----------------------------------------------------------------------------
       
    39 //  LOGGING MACROs 
       
    40 //-----------------------------------------------------------------------------
       
    41 
       
    42 // Logging method is defined in the mmp file
       
    43 
       
    44 #ifdef SCP_LOGGING_0
       
    45 
       
    46     #define ICPLOGSTRING(a)           
       
    47     #define ICPLOGSTRING2(a,b)     
       
    48     #define ICPLOGSTRING3(a,b,c)    
       
    49     #define ICPLOGSTRING4(a,b,c,d)
       
    50     #define ICPLOGSTRING5(a,b,c,d,e) 
       
    51 
       
    52 #endif
       
    53 
       
    54 #ifdef SCP_LOGGING_1
       
    55     #ifdef _DEBUG
       
    56         #include <e32def.h> 
       
    57         #include <e32svr.h>   
       
    58         #define ICPLOGSTRING(a)          { RDebug::Print(SCP_LIT_PRINT(a)); } 
       
    59         #define ICPLOGSTRING2(a,b)       { RDebug::Print(SCP_LIT_PRINT(a),b); } 
       
    60         #define ICPLOGSTRING3(a,b,c)     { RDebug::Print(SCP_LIT_PRINT(a),b,c); } 
       
    61         #define ICPLOGSTRING4(a,b,c,d)   { RDebug::Print(SCP_LIT_PRINT(a),b,c,d); }  
       
    62         #define ICPLOGSTRING5(a,b,c,d,e) { RDebug::Print(SCP_LIT_PRINT(a),b,c,d,e); }     
       
    63     #else
       
    64         #define ICPLOGSTRING(a)           
       
    65         #define ICPLOGSTRING2(a,b)     
       
    66         #define ICPLOGSTRING3(a,b,c)    
       
    67         #define ICPLOGSTRING4(a,b,c,d) 
       
    68         #define ICPLOGSTRING5(a,b,c,d,e) 
       
    69     #endif
       
    70 #endif
       
    71 
       
    72 #ifdef SCP_LOGGING_2
       
    73     //#ifdef _DEBUG
       
    74     	#define ICPLOGSTRING(a) { IcpDebugWriteFormat(SCP_LIT_PRINT(a)); } 
       
    75     	#define ICPLOGSTRING2(a,b) { IcpDebugWriteFormat(SCP_LIT_PRINT(a),b); } 
       
    76     	#define ICPLOGSTRING3(a,b,c) { IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c); }    
       
    77     	#define ICPLOGSTRING4(a,b,c,d) { IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c,d); };
       
    78         #define ICPLOGSTRING5(a,b,c,d,e) { IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c,d,e); };     
       
    79     /*#else
       
    80         #define ICPLOGSTRING(a)           
       
    81         #define ICPLOGSTRING2(a,b)     
       
    82         #define ICPLOGSTRING3(a,b,c)    
       
    83         #define ICPLOGSTRING4(a,b,c,d) 
       
    84         #define ICPLOGSTRING5(a,b,c,d,e) 
       
    85     #endif */
       
    86 #endif
       
    87 
       
    88 #ifdef SCP_LOGGING_3 
       
    89     #ifdef _DEBUG   
       
    90         #include <e32def.h> 
       
    91         #include <e32svr.h>   
       
    92         #define ICPLOGSTRING(a)          { RDebug::Print(SCP_LIT_PRINT(a));\
       
    93                                            IcpDebugWriteFormat(SCP_LIT_PRINT(a)); } 
       
    94         #define ICPLOGSTRING2(a,b)       { RDebug::Print(SCP_LIT_PRINT(a),b);\
       
    95                                            IcpDebugWriteFormat(SCP_LIT_PRINT(a),b); } 
       
    96         #define ICPLOGSTRING3(a,b,c)     { RDebug::Print(SCP_LIT_PRINT(a),b,c);\
       
    97                                            IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c); } 
       
    98         #define ICPLOGSTRING4(a,b,c,d)   { RDebug::Print(SCP_LIT_PRINT(a),b,c,d);\
       
    99                                            IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c,d); }  
       
   100         #define ICPLOGSTRING5(a,b,c,d,e) { RDebug::Print(SCP_LIT_PRINT(a),b,c,d,e);\
       
   101                                            IcpDebugWriteFormat(SCP_LIT_PRINT(a),b,c,d,e); }     
       
   102     #else
       
   103         #define ICPLOGSTRING(a)           
       
   104         #define ICPLOGSTRING2(a,b)     
       
   105         #define ICPLOGSTRING3(a,b,c)    
       
   106         #define ICPLOGSTRING4(a,b,c,d)
       
   107         #define ICPLOGSTRING5(a,b,c,d,e) 
       
   108     #endif     
       
   109 #endif
       
   110 
       
   111 #include <flogger.h>
       
   112 
       
   113 inline void IcpDebugWriteFormat(TRefByValue<const TDesC> aFmt,...)
       
   114     {
       
   115 #ifdef ICP_ENABLE_DEBUG_LOGS
       
   116     _LIT(KDir, "icp");
       
   117     _LIT(KName, "icp.log");
       
   118 
       
   119     // take the ellipsis parameters
       
   120     VA_LIST args;
       
   121     VA_START(args,aFmt);
       
   122     RFileLogger::WriteFormat(KDir, KName, EFileLoggingModeAppend, aFmt, args);
       
   123     VA_END(args);
       
   124 #endif
       
   125     }
       
   126 
       
   127 #endif  // __SCPLOGGER_H__