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