williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // Define Logging Service Constants, Macros and Definitions williamr@2: // intended for inclusion into any source file williamr@2: // which define classes wishing to use log server services. williamr@2: // williamr@2: // williamr@2: williamr@2: #if !defined(__LOGDEF_H__) williamr@2: #define __LOGDEF_H__ williamr@2: williamr@2: #if !defined(__E32BASE_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__ANSICOMP_H__) williamr@2: #include // Enforce ANSI compliance upon Microsoft Compilers williamr@2: #endif williamr@2: williamr@2: // This define removed for sanity and performance sake. To enable logging in williamr@2: // your component, redefine the __LOGGING macro in your own .cpp files, prior to williamr@2: // the #include of this file. williamr@2: // #define __LOGGING 1 williamr@2: williamr@2: /** williamr@2: Define a constant to control the maximum length of a log message williamr@2: @publishedAll williamr@2: @deprecated williamr@2: */ williamr@2: const TInt KMaxLogEntrySize = KMaxFileName; williamr@2: williamr@2: // Logging definitions williamr@2: #if defined (__LOGGING) && defined (_DEBUG) williamr@2: williamr@2: // Logging activity is enabled williamr@2: #if !defined(__CLOG_H__) williamr@2: #include "clog.h" williamr@2: #endif williamr@2: williamr@2: // Define an error message for failed open calls williamr@2: _LIT(KLogOpenFailed,"No log available"); williamr@2: williamr@2: // Define a set of macros to control logging activity williamr@2: // The log server client pointer williamr@2: #define __DECLARE_LOG CLogClient* iLogPtr; williamr@2: williamr@2: // Open a connection to the log server for appended log messages williamr@2: #define __OPEN_LOG(aLogName) {iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,EFalse))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);} williamr@2: // Open a connection to the log server for log messages to go to a clean log williamr@2: #define __OPEN_CLEANLOG(aLogName) {iLogPtr = NULL; TRAPD(logError,(iLogPtr = CLogClient::NewL(aLogName,ETrue))); if(logError !=KErrNone) __QINFO(KLogOpenFailed);} williamr@2: // Close the connection to the log server williamr@2: #define __CLOSE_LOG {delete iLogPtr; iLogPtr = NULL;} williamr@2: // Push and pop the log onto the cleanup stack williamr@2: #define __PUSHLOGL {CleanupStack::PushL(iLogPtr);} williamr@2: #define __POPLOG {CleanupStack::Pop();} williamr@2: williamr@2: // Log a simple message williamr@2: #define __LOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogLight);} williamr@2: // Log a message with single parameter formatting. williamr@2: #define __LOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogLight,aText,aV1);} williamr@2: williamr@2: #if defined (__PROFILING__) williamr@2: // Define additional macros for logging profiling information williamr@2: #define __PROFILELOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogProfile);} williamr@2: #define __PROFILELOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogProfile,aText,aV1);} williamr@2: #else williamr@2: // Empty macros for non-profiling builds williamr@2: #define __PROFILELOG(aText); williamr@2: #define __PROFILELOG1(aText,aV1); williamr@2: #endif williamr@2: williamr@2: // A log method entry macro williamr@2: #define __LOG_ENTER(aText) {if(iLogPtr != NULL) iLogPtr->LogEnter(aText,CLogClient::ELogProfile); } williamr@2: // A log method exit macro williamr@2: #define __LOG_RETURN {if(iLogPtr != NULL) iLogPtr->LogReturn(); } williamr@2: // Log a simple message at a particular level of detail williamr@2: #define __LOGX(aLevel,aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,aLevel);} williamr@2: // Log a simple message at a particular level of detail with single parameter formatting. williamr@2: #define __LOGX1(aLevel,aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(aLevel,aText,aV1);} williamr@2: // Log a simple message at trace level of detail williamr@2: #define __TRACELOG(aText) {if(iLogPtr != NULL) iLogPtr->Log(aText,CLogClient::ELogTrace); } williamr@2: // Log a simple message at trace level of detail with single parameter formatting. williamr@2: #define __TRACELOG1(aText,aV1) {if(iLogPtr != NULL) iLogPtr->Log(CLogClient::ELogTrace,aText,aV1);} williamr@2: // Show a simple message within the info window. williamr@2: #define __QINFO(aText) {User::InfoPrint(aText);} williamr@2: // Configuration of logging server behaviour williamr@2: // Turn on the RDebug::Print() when logging (Default setting) williamr@2: #define __ENABLE_LOGRDEBUG() {if(iLogPtr != NULL) iLogPtr->RDebugConfig(ETrue);} williamr@2: // Turn off the RDebug::Print() when logging williamr@2: #define __DISABLE_LOGRDEBUG() {if(iLogPtr != NULL) iLogPtr->RDebugConfig(EFalse);} williamr@2: williamr@2: #else williamr@2: #if !defined (_DEBUG) williamr@2: // In Release builds we want no macro definition whatsoever williamr@2: #define __DECLARE_LOG williamr@2: williamr@2: #else // In debug builds... williamr@2: // Empty macros for non-logging builds, except for __DECLARE_LOG - we want to ensure the williamr@2: // object sizes of classes are identical when headers are included in classes with a mixture williamr@2: // of __LOGGING turned on and off, to avoid nasty run-time linking errors. williamr@2: #define __DECLARE_LOG void* iLogPtrNotInUse; williamr@2: #endif williamr@2: #define __OPEN_LOG(aLogName) williamr@2: #define __OPEN_CLEANLOG(aLogName) williamr@2: #define __CLOSE_LOG williamr@2: #define __PUSHLOGL williamr@2: #define __POPLOG williamr@2: #define __LOG_ENTER(aText) williamr@2: #define __LOG_RETURN williamr@2: #define __LOG(aText) williamr@2: #define __LOG1(aText,aV1) williamr@2: #define __LOGX(aLevel,aText) williamr@2: #define __LOGX1(aLevel,aText,aV1) williamr@2: #define __PROFILELOG(aText) williamr@2: #define __PROFILELOG1(aText,aV1) williamr@2: #define __TRACELOG(aText) williamr@2: #define __TRACELOG1(aText,aV1) williamr@2: #define __QINFO(aText) williamr@2: #define __ENABLE_LOGRDEBUG() williamr@2: #define __DISABLE_LOGRDEBUG() williamr@2: williamr@2: #endif // __LOGGING williamr@2: williamr@2: #endif // __LOGDEF_H__