1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/logdef.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,135 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// 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
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Define Logging Service Constants, Macros and Definitions
1.18 +// intended for inclusion into any source file
1.19 +// which define classes wishing to use log server services.
1.20 +//
1.21 +//
1.22 +
1.23 +#if !defined(__LOGDEF_H__)
1.24 +#define __LOGDEF_H__
1.25 +
1.26 +#if !defined(__E32BASE_H__)
1.27 +#include <e32base.h>
1.28 +#endif
1.29 +
1.30 +#if !defined(__ANSICOMP_H__)
1.31 +#include <ansicomp.h> // Enforce ANSI compliance upon Microsoft Compilers
1.32 +#endif
1.33 +
1.34 +// This define removed for sanity and performance sake. To enable logging in
1.35 +// your component, redefine the __LOGGING macro in your own .cpp files, prior to
1.36 +// the #include of this file.
1.37 +// #define __LOGGING 1
1.38 +
1.39 +/**
1.40 +Define a constant to control the maximum length of a log message
1.41 +@publishedAll
1.42 +@deprecated
1.43 +*/
1.44 +const TInt KMaxLogEntrySize = KMaxFileName;
1.45 +
1.46 +// Logging definitions
1.47 +#if defined (__LOGGING) && defined (_DEBUG)
1.48 +
1.49 +// Logging activity is enabled
1.50 +#if !defined(__CLOG_H__)
1.51 +#include "clog.h"
1.52 +#endif
1.53 +
1.54 + // Define an error message for failed open calls
1.55 + _LIT(KLogOpenFailed,"No log available");
1.56 +
1.57 + // Define a set of macros to control logging activity
1.58 + // The log server client pointer
1.59 + #define __DECLARE_LOG CLogClient* iLogPtr;
1.60 +
1.61 + // Open a connection to the log server for appended log messages
1.62 + #define __OPEN_LOG(aLogName) {iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,EFalse))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);}
1.63 + // Open a connection to the log server for log messages to go to a clean log
1.64 + #define __OPEN_CLEANLOG(aLogName) {iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,ETrue))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);}
1.65 + // Close the connection to the log server
1.66 + #define __CLOSE_LOG {delete iLogPtr; iLogPtr = NULL;}
1.67 + // Push and pop the log onto the cleanup stack
1.68 + #define __PUSHLOGL {CleanupStack::PushL(iLogPtr);}
1.69 + #define __POPLOG {CleanupStack::Pop();}
1.70 +
1.71 + // Log a simple message
1.72 + #define __LOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogLight);}
1.73 + // Log a message with single parameter formatting.
1.74 + #define __LOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogLight,aText,aV1);}
1.75 +
1.76 + #if defined (__PROFILING__)
1.77 + // Define additional macros for logging profiling information
1.78 + #define __PROFILELOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogProfile);}
1.79 + #define __PROFILELOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogProfile,aText,aV1);}
1.80 + #else
1.81 + // Empty macros for non-profiling builds
1.82 + #define __PROFILELOG(aText);
1.83 + #define __PROFILELOG1(aText,aV1);
1.84 + #endif
1.85 +
1.86 + // A log method entry macro
1.87 + #define __LOG_ENTER(aText) {if(iLogPtr != NULL) iLogPtr->LogEnter(aText,CLogClient::ELogProfile); }
1.88 + // A log method exit macro
1.89 + #define __LOG_RETURN {if(iLogPtr != NULL) iLogPtr->LogReturn(); }
1.90 + // Log a simple message at a particular level of detail
1.91 + #define __LOGX(aLevel,aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,aLevel);}
1.92 + // Log a simple message at a particular level of detail with single parameter formatting.
1.93 + #define __LOGX1(aLevel,aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(aLevel,aText,aV1);}
1.94 + // Log a simple message at trace level of detail
1.95 + #define __TRACELOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogTrace); }
1.96 + // Log a simple message at trace level of detail with single parameter formatting.
1.97 + #define __TRACELOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogTrace,aText,aV1);}
1.98 + // Show a simple message within the info window.
1.99 + #define __QINFO(aText) {User::InfoPrint(aText);}
1.100 + // Configuration of logging server behaviour
1.101 + // Turn on the RDebug::Print() when logging (Default setting)
1.102 + #define __ENABLE_LOGRDEBUG() {if(iLogPtr != NULL) iLogPtr->RDebugConfig(ETrue);}
1.103 + // Turn off the RDebug::Print() when logging
1.104 + #define __DISABLE_LOGRDEBUG() {if(iLogPtr != NULL) iLogPtr->RDebugConfig(EFalse);}
1.105 +
1.106 +#else
1.107 + #if !defined (_DEBUG)
1.108 + // In Release builds we want no macro definition whatsoever
1.109 + #define __DECLARE_LOG
1.110 +
1.111 + #else // In debug builds...
1.112 + // Empty macros for non-logging builds, except for __DECLARE_LOG - we want to ensure the
1.113 + // object sizes of classes are identical when headers are included in classes with a mixture
1.114 + // of __LOGGING turned on and off, to avoid nasty run-time linking errors.
1.115 + #define __DECLARE_LOG void* iLogPtrNotInUse;
1.116 + #endif
1.117 + #define __OPEN_LOG(aLogName)
1.118 + #define __OPEN_CLEANLOG(aLogName)
1.119 + #define __CLOSE_LOG
1.120 + #define __PUSHLOGL
1.121 + #define __POPLOG
1.122 + #define __LOG_ENTER(aText)
1.123 + #define __LOG_RETURN
1.124 + #define __LOG(aText)
1.125 + #define __LOG1(aText,aV1)
1.126 + #define __LOGX(aLevel,aText)
1.127 + #define __LOGX1(aLevel,aText,aV1)
1.128 + #define __PROFILELOG(aText)
1.129 + #define __PROFILELOG1(aText,aV1)
1.130 + #define __TRACELOG(aText)
1.131 + #define __TRACELOG1(aText,aV1)
1.132 + #define __QINFO(aText)
1.133 + #define __ENABLE_LOGRDEBUG()
1.134 + #define __DISABLE_LOGRDEBUG()
1.135 +
1.136 +#endif // __LOGGING
1.137 +
1.138 +#endif // __LOGDEF_H__