sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * This header contains definitions for logging commands. sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: sl@0: #ifndef __OCSP_LOG_H__ sl@0: #define __OCSP_LOG_H__ sl@0: sl@0: #include sl@0: sl@0: namespace OCSP sl@0: { sl@0: sl@0: #ifdef _DEBUG sl@0: sl@0: #define DEBUG_PRINTF(a) {OCSP::DebugPrintf(__LINE__, __FILE__, a);} sl@0: #define DEBUG_PRINTF2(a, b) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b);} sl@0: #define DEBUG_PRINTF3(a, b, c) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c);} sl@0: #define DEBUG_PRINTF4(a, b, c, d) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d);} sl@0: #define DEBUG_PRINTF5(a, b, c, d, e) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d, e);} sl@0: sl@0: #define DEBUG_CODE_SECTION(a) TRAP_IGNORE({ a; }) sl@0: sl@0: // UTF-8 overload of the DebufPrintf method. Should be used by default, sl@0: // since it's cheaper both in CPU cycles and stack space. sl@0: sl@0: inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue aFormat, ...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list, aFormat); sl@0: sl@0: TTime now; sl@0: now.HomeTime(); sl@0: sl@0: TBuf8<1024> buffer; sl@0: _LIT8(KSwiLogPrefix, "[OCSP] "); sl@0: _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- "); sl@0: buffer.Append(KSwiLogPrefix); sl@0: buffer.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile); sl@0: buffer.AppendFormatList(aFormat, list); sl@0: buffer.Append(_L8("\r\n")); sl@0: sl@0: RDebug::RawPrint(buffer); sl@0: sl@0: VA_END(list); sl@0: } sl@0: sl@0: // Unicode DebufPrintf overload sl@0: sl@0: inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue aFormat, ...) sl@0: { sl@0: VA_LIST list; sl@0: VA_START(list, aFormat); sl@0: sl@0: TTime now; sl@0: now.HomeTime(); sl@0: sl@0: TBuf8<256> header; sl@0: _LIT8(KSwiLogPrefix, "[SWI] "); sl@0: _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- "); sl@0: header.Append(KSwiLogPrefix); sl@0: header.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile); sl@0: sl@0: TBuf<1024> buffer; sl@0: buffer.Copy(header); sl@0: buffer.AppendFormatList(aFormat, list); sl@0: buffer.Append(_L("\r\n")); sl@0: sl@0: RDebug::RawPrint(buffer); sl@0: sl@0: VA_END(list); sl@0: } sl@0: sl@0: #else sl@0: sl@0: #define DEBUG_PRINTF(a) sl@0: #define DEBUG_PRINTF2(a, b) sl@0: #define DEBUG_PRINTF3(a, b, c) sl@0: #define DEBUG_PRINTF4(a, b, c, d) sl@0: #define DEBUG_PRINTF5(a, b, c, d, e) sl@0: sl@0: #define DEBUG_CODE_SECTION(a) sl@0: sl@0: #endif sl@0: sl@0: sl@0: } // namespace Swi sl@0: sl@0: #endif // __OCSP_LOG_H__