epoc32/include/logdef.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Define Logging Service Constants, Macros and Definitions 
       
    15 // intended for inclusion into any source file
       
    16 // which define classes wishing to use log server services.
       
    17 // 
       
    18 //
       
    19 
       
    20 #if !defined(__LOGDEF_H__)
       
    21 #define __LOGDEF_H__
       
    22 
       
    23 #if !defined(__E32BASE_H__)
       
    24 #include <e32base.h>
       
    25 #endif
       
    26 
       
    27 #if !defined(__ANSICOMP_H__)
       
    28 #include <ansicomp.h>	// Enforce ANSI compliance upon Microsoft Compilers
       
    29 #endif
       
    30 
       
    31 // This define removed for sanity and performance sake.  To enable logging in
       
    32 // your component, redefine the __LOGGING macro in your own .cpp files, prior to
       
    33 // the #include of this file.
       
    34 // #define __LOGGING 1
       
    35 
       
    36 /**
       
    37 Define a constant to control the maximum length of a log message
       
    38 @publishedAll
       
    39 @deprecated
       
    40 */
       
    41 const TInt KMaxLogEntrySize = KMaxFileName;
       
    42 
       
    43 // Logging definitions
       
    44 #if defined (__LOGGING) && 	defined (_DEBUG)		
       
    45 
       
    46 // Logging activity is enabled
       
    47 #if !defined(__CLOG_H__)
       
    48 #include "clog.h"
       
    49 #endif
       
    50 
       
    51 	// Define an error message for failed open calls
       
    52 	_LIT(KLogOpenFailed,"No log available");
       
    53 
       
    54 	// Define a set of macros to control logging activity
       
    55 	// The log server client pointer
       
    56 	#define __DECLARE_LOG					CLogClient* iLogPtr;
       
    57 
       
    58 	// Open a connection to the log server for appended log messages
       
    59 	#define __OPEN_LOG(aLogName)			{iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,EFalse))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);}
       
    60 	// Open a connection to the log server for log messages to go to a clean log
       
    61 	#define __OPEN_CLEANLOG(aLogName)		{iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,ETrue))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);}
       
    62 	// Close the connection to the log server
       
    63 	#define __CLOSE_LOG						{delete iLogPtr; iLogPtr = NULL;}
       
    64 	// Push and pop the log onto the cleanup stack
       
    65 	#define __PUSHLOGL						{CleanupStack::PushL(iLogPtr);}
       
    66 	#define __POPLOG						{CleanupStack::Pop();}
       
    67 	
       
    68 	// Log a simple message
       
    69 	#define __LOG(aText)					{if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogLight);}
       
    70 	// Log a message with single parameter formatting.
       
    71 	#define __LOG1(aText,aV1)				{if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogLight,aText,aV1);}
       
    72 
       
    73 	#if defined (__PROFILING__)
       
    74 	// Define additional macros for logging profiling information
       
    75 		#define __PROFILELOG(aText)			{if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogProfile);}
       
    76 		#define __PROFILELOG1(aText,aV1)	{if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogProfile,aText,aV1);}
       
    77 	#else
       
    78 	// Empty macros for non-profiling builds
       
    79 		#define __PROFILELOG(aText);
       
    80 		#define __PROFILELOG1(aText,aV1);
       
    81 	#endif
       
    82 
       
    83 	// A log method entry macro
       
    84 	#define __LOG_ENTER(aText)			{if(iLogPtr != NULL) iLogPtr->LogEnter(aText,CLogClient::ELogProfile); }
       
    85 	// A log method exit macro
       
    86 	#define __LOG_RETURN				{if(iLogPtr != NULL) iLogPtr->LogReturn(); }
       
    87 	// Log a simple message at a particular level of detail
       
    88 	#define __LOGX(aLevel,aText)		{if(iLogPtr != NULL) iLogPtr->Log(aText,aLevel);}
       
    89 	// Log a simple message at a particular level of detail with single parameter formatting.
       
    90 	#define __LOGX1(aLevel,aText,aV1)	{if(iLogPtr != NULL) iLogPtr->Log(aLevel,aText,aV1);}
       
    91 	// Log a simple message at trace level of detail
       
    92 	#define __TRACELOG(aText)			{if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogTrace); }
       
    93 	// Log a simple message at trace level of detail with single parameter formatting.
       
    94 	#define __TRACELOG1(aText,aV1)		{if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogTrace,aText,aV1);}
       
    95 	// Show a simple message within the info window.
       
    96 	#define __QINFO(aText)				{User::InfoPrint(aText);} 
       
    97 	// Configuration of logging server behaviour
       
    98 	// Turn on the RDebug::Print() when logging (Default setting)
       
    99 	#define __ENABLE_LOGRDEBUG()		{if(iLogPtr != NULL) iLogPtr->RDebugConfig(ETrue);} 
       
   100 	// Turn off the RDebug::Print() when logging
       
   101 	#define __DISABLE_LOGRDEBUG()		{if(iLogPtr != NULL) iLogPtr->RDebugConfig(EFalse);} 
       
   102 
       
   103 #else
       
   104   #if !defined (_DEBUG)
       
   105 	// In Release builds we want no macro definition whatsoever
       
   106 	#define __DECLARE_LOG
       
   107 
       
   108   #else	// In debug builds...
       
   109 	// Empty macros for non-logging builds, except for __DECLARE_LOG - we want to ensure the
       
   110 	// object sizes of classes are identical when headers are included in classes with a mixture
       
   111 	// of __LOGGING turned on and off, to avoid nasty run-time linking errors.
       
   112 	#define __DECLARE_LOG				void* iLogPtrNotInUse;
       
   113   #endif
       
   114 	#define __OPEN_LOG(aLogName)
       
   115 	#define __OPEN_CLEANLOG(aLogName)
       
   116 	#define __CLOSE_LOG
       
   117 	#define __PUSHLOGL
       
   118 	#define __POPLOG
       
   119 	#define __LOG_ENTER(aText)
       
   120 	#define __LOG_RETURN 
       
   121 	#define __LOG(aText)
       
   122 	#define __LOG1(aText,aV1)
       
   123 	#define __LOGX(aLevel,aText)
       
   124 	#define __LOGX1(aLevel,aText,aV1)
       
   125 	#define __PROFILELOG(aText)
       
   126 	#define __PROFILELOG1(aText,aV1)
       
   127 	#define __TRACELOG(aText)
       
   128 	#define __TRACELOG1(aText,aV1)
       
   129 	#define __QINFO(aText)
       
   130 	#define __ENABLE_LOGRDEBUG()
       
   131 	#define __DISABLE_LOGRDEBUG()
       
   132 
       
   133 #endif	// __LOGGING
       
   134 
       
   135 #endif	// __LOGDEF_H__