multimediacommsengine/mmcecli/inc/mceclilogs.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef MCECLILOGS_H
       
    24 #define MCECLILOGS_H
       
    25 
       
    26 #include "mcecomlogs.h"
       
    27 #include "mceevents.h"
       
    28 #include "mceclientserver.h"
       
    29 #include "mcesession.h"
       
    30 
       
    31 // INCLUDES
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 #ifdef MCECLI_UNIT_TEST_COVERAGE
       
    38 
       
    39 #undef _DEBUG
       
    40 
       
    41 #endif
       
    42 
       
    43 /**
       
    44  * Class provides logging through RDebug in debug builds
       
    45  * 'MCE: ' added automatically in fron of every logged line
       
    46  */ 
       
    47 class TMceCliDebug 
       
    48 	{
       
    49 	public:
       
    50 
       
    51 #ifdef _DEBUG
       
    52 
       
    53 	inline static void Print(const TDesC16& aStr) 
       
    54 		{
       
    55 		TChar notAllowed('%');
       
    56 		if ( aStr.Locate( notAllowed ) == KErrNotFound )
       
    57 			{
       
    58 			_LIT(KMceFormat, "[Client] %S");
       
    59 
       
    60 			TBuf<256> str;
       
    61 			str.Format(KMceFormat, &aStr);
       
    62 			TMceDebug::Print( str, ETrue );
       
    63 			}
       
    64 		else
       
    65 			{
       
    66 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
    67 			RDebug::Print( KMceWarning );							
       
    68 			}	
       
    69 		}
       
    70 
       
    71 	inline static void Print(const TDesC16& aStr1, TUint32 aValue1 )
       
    72 		{
       
    73 		TChar notAllowed('%');
       
    74 		if ( aStr1.Locate( notAllowed ) == KErrNotFound )
       
    75 			{
       
    76 			_LIT(KMceFormat, "[Client] %S=%d");
       
    77 			TBuf<256> str;
       
    78 			str.Format(KMceFormat, &aStr1, aValue1);
       
    79 			TMceDebug::Print( str, ETrue );
       
    80 			}
       
    81 		else
       
    82 			{
       
    83 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
    84 			RDebug::Print( KMceWarning );							
       
    85 			}	
       
    86 		}
       
    87 
       
    88 	inline static void Print( const TDesC16& aStr1, const TDesC16& aStr2 )
       
    89 		{
       
    90 		TChar notAllowed('%');
       
    91 		if ( aStr1.Locate( notAllowed ) == KErrNotFound  &&
       
    92 		     aStr2.Locate( notAllowed ) == KErrNotFound )
       
    93 			{
       
    94 			_LIT(KMceFormat, "[Client] %S=%S");
       
    95 			TBuf<256> str;
       
    96 			str.Format(KMceFormat, &aStr1, &aStr2);
       
    97 			TMceDebug::Print( str, ETrue );
       
    98 			}
       
    99 		else
       
   100 			{
       
   101 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
   102 			RDebug::Print( KMceWarning );							
       
   103 			}	
       
   104 		}
       
   105 
       
   106 	inline static void Print(const TDesC16& aStr1, TUint32 aValue1, const TDesC16& aStr2, TUint32 aValue2 ) 
       
   107 		{
       
   108 		TChar notAllowed('%');
       
   109 		if ( aStr1.Locate( notAllowed ) == KErrNotFound )
       
   110 			{
       
   111 			_LIT(KMceFormat, "[Client] %S=%d, %S=%d");
       
   112 			TBuf<256> str;
       
   113 			str.Format(KMceFormat, &aStr1, aValue1, &aStr2, aValue2 );
       
   114 			TMceDebug::Print( str );
       
   115 			}
       
   116 		else
       
   117 			{
       
   118 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
   119 			RDebug::Print( KMceWarning );							
       
   120 			}	
       
   121 		}
       
   122 
       
   123 	inline static void Print(const TDesC16& aStr1, TUint32 aValue1, 
       
   124 	                         const TDesC16& aStr2, TUint32 aValue2,
       
   125 	                         const TDesC16& aStr3, TUint32 aValue3 )
       
   126 		{
       
   127 		TChar notAllowed('%');
       
   128 		if ( aStr1.Locate( notAllowed ) == KErrNotFound )
       
   129 			{
       
   130 			_LIT(KMceFormat, "[Client] %S=%d, %S=%d, %S=%d");
       
   131 			TBuf<256> str;
       
   132 			str.Format(KMceFormat, &aStr1, aValue1, &aStr2, aValue2, &aStr3, aValue3 );
       
   133 			TMceDebug::Print( str );
       
   134 			}
       
   135 		else
       
   136 			{
       
   137 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
   138 			RDebug::Print( KMceWarning );							
       
   139 			}	
       
   140 		}
       
   141 
       
   142 	inline static void Print(const TDesC16& aStr1, TUint32 aValue1, const TDesC16& aStr2 ) 
       
   143 		{
       
   144 		TChar notAllowed('%');
       
   145 		if ( aStr1.Locate( notAllowed ) == KErrNotFound )
       
   146 			{
       
   147 			_LIT(KMceFormat, "[Client] %S=%d %S");
       
   148 			TBuf<256> str;
       
   149 			str.Format(KMceFormat, &aStr1, aValue1, &aStr2 );
       
   150 			TMceDebug::Print( str );
       
   151 			}
       
   152 		else
       
   153 			{
       
   154 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
   155 			RDebug::Print( KMceWarning );							
       
   156 			}	
       
   157 		}
       
   158 
       
   159 	inline static void Print( const TDesC16& aStr1, const TDesC8& aValue1 ) 
       
   160 	    {
       
   161 		TChar notAllowed('%');
       
   162 		if ( aStr1.Locate( notAllowed ) == KErrNotFound )
       
   163 			{
       
   164 			TBuf<100> str2;
       
   165 			CnvUtfConverter::ConvertToUnicodeFromUtf8(str2, aValue1);
       
   166 
       
   167 			_LIT(KMceFormat, "[Client] %S=\"%S\"");
       
   168 			TBuf<256> str;
       
   169 			str.Format(KMceFormat, &aStr1, &str2);
       
   170 			TMceDebug::Print( str );
       
   171 			}
       
   172 		else
       
   173 			{
       
   174 			_LIT(KMceWarning, "MCE: Text contains not allowed characters, log ignored");
       
   175 			RDebug::Print( KMceWarning );							
       
   176 			}		    
       
   177 	    }
       
   178 	    
       
   179 
       
   180 #endif
       
   181 
       
   182 	};
       
   183 
       
   184 
       
   185 #ifdef _DEBUG 
       
   186 
       
   187 #define MCECLI_DEBUG( a ) { TMceCliDebug::Print( _L( a ) ); }
       
   188 #define MCECLI_DEBUG2( a, b ) { TMceCliDebug::Print( _L( a ), _L( b ) ); }
       
   189 #define MCECLI_DEBUG_DVALUE( a, b ) { TMceCliDebug::Print( _L( a ),  b  ); }
       
   190 #define MCECLI_DEBUG_DVALUES( a, b, c, d ) { TMceCliDebug::Print( _L( a ),  b, _L( c ), d  ); }
       
   191 #define MCECLI_DEBUG_DVALUES2( a, b, c, d, e, f ) { TMceCliDebug::Print( _L( a ),  b, _L( c ), d, _L( e ), f ); }
       
   192 #define MCECLI_DEBUG_SVALUE( a, b ) { TMceCliDebug::Print( _L( a ), b ); }
       
   193 #define MCECLI_DEBUG_SVALUE16( a, b ) { TMceCliDebug::Print( _L( a ), b ); }
       
   194 
       
   195     
       
   196 #define MCECLI_DEBUG_CALLBACK( str, callback )\
       
   197         MCE_DEBUG_CALLBACK( TMceCliDebug, str, callback )
       
   198 
       
   199 #define MCECLI_DEBUG_DATATYPE( str, datatype )\
       
   200         MCE_DEBUG_DATATYPE( TMceCliDebug, str, datatype )
       
   201         
       
   202 #define MCECLI_DEBUG_CLISTATE( str, state )\
       
   203         MCE_DEBUG_CLISTATE( TMceCliDebug, str, state )
       
   204         
       
   205 #define MCECLI_DEBUG_ITC( str, event )\
       
   206         MCE_DEBUG_ITC( TMceCliDebug, str, event )
       
   207 
       
   208 #define MCECLI_DEBUG_SESSIONTYPE( str, type )\
       
   209         MCE_DEBUG_SESSIONTYPE( TMceCliDebug, str, type )
       
   210 
       
   211 #define MCECLI_DEBUG_DIALOGTYPE( str, type )\
       
   212         MCE_DEBUG_DIALOGTYPE( TMceCliDebug, str, type )
       
   213 
       
   214 #define MCECLI_DEBUG_MEDIASTATE( str, state )\
       
   215         MCE_DEBUG_MEDIASTATE( TMceCliDebug, str, state )
       
   216 
       
   217 #define MCECLI_DEBUG_EVENTSTATE( str, state )\
       
   218         MCE_DEBUG_EVENTSTATE( TMceCliDebug, str, state )
       
   219 
       
   220 
       
   221         
       
   222 #define MCECLI_DEBUG_IDS( str, ids )\
       
   223     MCECLI_DEBUG( str );\
       
   224     MCECLI_DEBUG_DVALUE("application uid", ids.iAppUID );\
       
   225     MCECLI_DEBUG_SESSIONTYPE("session type", ids.iManagerType );\
       
   226     MCECLI_DEBUG_DVALUE("session id", ids.iSessionID );\
       
   227     MCECLI_DEBUG_DIALOGTYPE("dialog type", ids.iDialogType );\
       
   228     MCECLI_DEBUG_DVALUE("dialog id", ids.iDialogID );\
       
   229     MCECLI_DEBUG_DVALUE("profile id", ids.iProfileID );\
       
   230     MCECLI_DEBUG_DATATYPE("message type", ids.iMsgType );\
       
   231     MCECLI_DEBUG_CALLBACK( "callback", ids.iCallbackID );\
       
   232     MCECLI_DEBUG_DVALUE( "status", ids.iStatus );\
       
   233     MCECLI_DEBUG_DVALUE("media id", ids.iMediaID.iId );\
       
   234     MCECLI_DEBUG_DVALUE("source id", ids.iSourceID.iId );\
       
   235     MCECLI_DEBUG_DVALUE("sink id", ids.iSinkID.iId );\
       
   236     MCECLI_DEBUG_DVALUE("codec id", ids.iCodecID.iId )
       
   237 
       
   238 
       
   239 
       
   240 #else
       
   241 
       
   242 
       
   243 #define MCECLI_DEBUG( a )
       
   244 #define MCECLI_DEBUG2( a, b )
       
   245 #define MCECLI_DEBUG_DVALUE( a, b )
       
   246 #define MCECLI_DEBUG_DVALUES( a, b, c, d )
       
   247 #define MCECLI_DEBUG_DVALUES2( a, b, c, d, e, f )
       
   248 #define MCECLI_DEBUG_SVALUE( a, b )
       
   249 #define MCECLI_DEBUG_CLISTATE( str, state )
       
   250 #define MCECLI_DEBUG_DATATYPE( str, datatype )
       
   251 #define MCECLI_DEBUG_ITC( str, event )
       
   252 #define MCECLI_DEBUG_IDS( str, ids )
       
   253 #define MCECLI_DEBUG_CALLBACK( str, callback )
       
   254 #define MCECLI_DEBUG_SESSIONTYPE( str, type )
       
   255 #define MCECLI_DEBUG_DIALOGTYPE( str, type )
       
   256 #define MCECLI_DEBUG_MEDIASTATE( str, state )
       
   257 #define MCECLI_DEBUG_EVENTSTATE( str, state )
       
   258 
       
   259 #endif
       
   260 
       
   261 #endif
       
   262 
       
   263 // End of File