backupandrestore/backuptest/ABTester/inc/abtesterlog.h
changeset 0 d0791faffa3f
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 /**
       
     2 * Copyright (c) 2004-2009 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 * Logging utilities
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file
       
    24 */
       
    25 
       
    26 #ifndef __ABTESTERLOG_H__
       
    27 #define __ABTESTERLOG_H__
       
    28 
       
    29 #ifndef __FLOGGER_H__
       
    30 #include <flogger.h>
       
    31 #endif
       
    32 
       
    33 #ifndef __E32STD_H__
       
    34 #include <e32std.h>
       
    35 #endif
       
    36 
       
    37 namespace conn
       
    38 	{
       
    39     /**
       
    40     @defgroup Log Log
       
    41 
       
    42     This module implements logging utilities. Information is currently
       
    43     logged via flogger, but this can be easily changed as logging is
       
    44     hidden by global macros.
       
    45 
       
    46     The log control macros allow enabling or disabling of the following
       
    47     type of logging:-
       
    48 
       
    49     @li UI logging (a message is displayed top right of the screen) see
       
    50     __DISPLAY_LOG_MESSAGES.
       
    51 
       
    52     @li flogger logging (a message is displayed in the flogger log file) see
       
    53     __DISPLAY_FLOG_MESSAGES.
       
    54 
       
    55     A nested namespace, SBServerLog, contains the class and global function that
       
    56     performs the logging operations: TLog, OpenLog(), CloseLog() and TLog
       
    57     operator() - which accepts a variable number of arguments. There is
       
    58     macro for each of these functions.
       
    59 
       
    60     OpenLog() and CloseLog() must be called only once and this is done by
       
    61     MainL().
       
    62     */ 
       
    63     
       
    64 	/** LOG CONTROL MACROS */
       
    65 
       
    66     /** @{ */
       
    67 	
       
    68 	#if (defined(ABT_LOGGING_DEBUG_ONLY) && defined(_DEBUG)) || defined(ABT_LOGGING_DEBUG_AND_RELEASE)
       
    69 
       
    70         #define ABT_LOGGING_ENABLED
       
    71 		
       
    72 		namespace ABTesterLog
       
    73     	/**
       
    74     	@ingroup Log
       
    75         	This namespace hides the internal of logging from the rest of the system.
       
    76 	    */
       
    77     	    {
       
    78 			void __Log(TRefByValue<const TDesC> aFmt,...);	
       
    79 	    	}//ABTesterLog
       
    80 	    	
       
    81 	    /** Logs a message */
       
    82 		#define __LOG(TXT) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText);}	
       
    83 
       
    84 	    /** Logs a message plus an additional value. The text must
       
    85 	     contain an appropriate printf alike indication, e.g. %d if the additional
       
    86 	    value is an integer. */
       
    87 	    #define __LOG1(TXT, A) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A);}	
       
    88 
       
    89 	    /** Logs a message plus two additional values. The text must
       
    90 	     contain two appropriate printf alike indications.*/
       
    91 	    #define __LOG2(TXT, A, B) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A, B);}
       
    92 	    
       
    93 	    /** Logs a message plus two additional values. The text must
       
    94 	     contain two appropriate printf alike indications.*/
       
    95 	    #define __LOG3(TXT, A, B, C) {_LIT(__KText,TXT); ABTesterLog::__Log(__KText, A, B, C);}	
       
    96 
       
    97 		
       
    98 		/** Log Utility macro. 
       
    99 		Executes the function specified under a trap and if the
       
   100 		error code is not KErrNone logs the message specified before
       
   101 		leaving. Note that the message must have a '%d' in it!*/
       
   102 		#define __EXECLOGL(F, STR) 	TRAPD(__r, F);\
       
   103 			if (__r != KErrNone) { __LOG1(STR, __r); User::Leave(__r); }
       
   104 			
       
   105 	#else
       
   106 		
       
   107 		#define __LOG(TXT)
       
   108         #define __LOG1(TXT, A)
       
   109         #define __LOG2(TXT, A, B)
       
   110         #define __LOG3(TXT, A, B, C )
       
   111         
       
   112 	#endif
       
   113     /** @} */
       
   114 
       
   115 	
       
   116 	}//conn
       
   117 		
       
   118 #endif //__SBSSLOG_H__