1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptoservices/certificateandkeymgmt/swicertstore/log.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,108 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* This header contains definitions for logging commands.
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalComponent
1.26 +*/
1.27 +
1.28 +#ifndef __OCSP_LOG_H__
1.29 +#define __OCSP_LOG_H__
1.30 +
1.31 +#include <e32debug.h>
1.32 +
1.33 +namespace OCSP
1.34 +{
1.35 +
1.36 +#ifdef _DEBUG
1.37 +
1.38 +#define DEBUG_PRINTF(a) {OCSP::DebugPrintf(__LINE__, __FILE__, a);}
1.39 +#define DEBUG_PRINTF2(a, b) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b);}
1.40 +#define DEBUG_PRINTF3(a, b, c) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c);}
1.41 +#define DEBUG_PRINTF4(a, b, c, d) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d);}
1.42 +#define DEBUG_PRINTF5(a, b, c, d, e) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d, e);}
1.43 +
1.44 +#define DEBUG_CODE_SECTION(a) TRAP_IGNORE({ a; })
1.45 +
1.46 +// UTF-8 overload of the DebufPrintf method. Should be used by default,
1.47 +// since it's cheaper both in CPU cycles and stack space.
1.48 +
1.49 +inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC8> aFormat, ...)
1.50 + {
1.51 + VA_LIST list;
1.52 + VA_START(list, aFormat);
1.53 +
1.54 + TTime now;
1.55 + now.HomeTime();
1.56 +
1.57 + TBuf8<1024> buffer;
1.58 + _LIT8(KSwiLogPrefix, "[OCSP] ");
1.59 + _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
1.60 + buffer.Append(KSwiLogPrefix);
1.61 + buffer.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile);
1.62 + buffer.AppendFormatList(aFormat, list);
1.63 + buffer.Append(_L8("\r\n"));
1.64 +
1.65 + RDebug::RawPrint(buffer);
1.66 +
1.67 + VA_END(list);
1.68 + }
1.69 +
1.70 +// Unicode DebufPrintf overload
1.71 +
1.72 +inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC16> aFormat, ...)
1.73 + {
1.74 + VA_LIST list;
1.75 + VA_START(list, aFormat);
1.76 +
1.77 + TTime now;
1.78 + now.HomeTime();
1.79 +
1.80 + TBuf8<256> header;
1.81 + _LIT8(KSwiLogPrefix, "[SWI] ");
1.82 + _LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
1.83 + header.Append(KSwiLogPrefix);
1.84 + header.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile);
1.85 +
1.86 + TBuf<1024> buffer;
1.87 + buffer.Copy(header);
1.88 + buffer.AppendFormatList(aFormat, list);
1.89 + buffer.Append(_L("\r\n"));
1.90 +
1.91 + RDebug::RawPrint(buffer);
1.92 +
1.93 + VA_END(list);
1.94 + }
1.95 +
1.96 +#else
1.97 +
1.98 +#define DEBUG_PRINTF(a)
1.99 +#define DEBUG_PRINTF2(a, b)
1.100 +#define DEBUG_PRINTF3(a, b, c)
1.101 +#define DEBUG_PRINTF4(a, b, c, d)
1.102 +#define DEBUG_PRINTF5(a, b, c, d, e)
1.103 +
1.104 +#define DEBUG_CODE_SECTION(a)
1.105 +
1.106 +#endif
1.107 +
1.108 +
1.109 +} // namespace Swi
1.110 +
1.111 +#endif // __OCSP_LOG_H__