os/security/cryptoservices/certificateandkeymgmt/swicertstore/log.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * This header contains definitions for logging commands.
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file 
    22  @internalComponent
    23 */
    24 
    25 #ifndef __OCSP_LOG_H__
    26 #define __OCSP_LOG_H__
    27 
    28 #include <e32debug.h>
    29 
    30 namespace OCSP
    31 {
    32 
    33 #ifdef _DEBUG
    34 
    35 #define DEBUG_PRINTF(a) {OCSP::DebugPrintf(__LINE__, __FILE__, a);}
    36 #define DEBUG_PRINTF2(a, b) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b);}
    37 #define DEBUG_PRINTF3(a, b, c) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c);}
    38 #define DEBUG_PRINTF4(a, b, c, d) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d);}
    39 #define DEBUG_PRINTF5(a, b, c, d, e) {OCSP::DebugPrintf(__LINE__, __FILE__, a, b, c, d, e);}
    40 
    41 #define DEBUG_CODE_SECTION(a) TRAP_IGNORE({ a; }) 
    42 
    43 // UTF-8 overload of the DebufPrintf method. Should be used by default,
    44 // since it's cheaper both in CPU cycles and stack space.
    45 
    46 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC8> aFormat, ...)
    47 	{
    48 	VA_LIST list;
    49 	VA_START(list, aFormat);
    50 	
    51 	TTime now;
    52 	now.HomeTime();
    53 	
    54 	TBuf8<1024> buffer;
    55 	_LIT8(KSwiLogPrefix, "[OCSP] ");
    56 	_LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
    57 	buffer.Append(KSwiLogPrefix);
    58 	buffer.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile);
    59 	buffer.AppendFormatList(aFormat, list);
    60 	buffer.Append(_L8("\r\n"));
    61 	
    62 	RDebug::RawPrint(buffer);
    63 	
    64 	VA_END(list);
    65 	}
    66 	
    67 // Unicode DebufPrintf overload
    68 
    69 inline void DebugPrintf(TInt aLine, char* aFile, TRefByValue<const TDesC16> aFormat, ...)
    70 	{
    71 	VA_LIST list;
    72 	VA_START(list, aFormat);
    73 	
    74 	TTime now;
    75 	now.HomeTime();
    76 	
    77 	TBuf8<256> header;
    78 	_LIT8(KSwiLogPrefix, "[SWI] ");
    79 	_LIT8(KSwiLineFileFormat, "%Ld Line: % 5d, File: %s -- ");
    80 	header.Append(KSwiLogPrefix);
    81 	header.AppendFormat(KSwiLineFileFormat, now.Int64(), aLine, aFile);
    82 	
    83 	TBuf<1024> buffer;
    84 	buffer.Copy(header);
    85 	buffer.AppendFormatList(aFormat, list);
    86 	buffer.Append(_L("\r\n"));
    87 	
    88 	RDebug::RawPrint(buffer);
    89 	
    90 	VA_END(list);
    91 	}
    92 
    93 #else
    94 
    95 #define DEBUG_PRINTF(a)
    96 #define DEBUG_PRINTF2(a, b)
    97 #define DEBUG_PRINTF3(a, b, c)
    98 #define DEBUG_PRINTF4(a, b, c, d)
    99 #define DEBUG_PRINTF5(a, b, c, d, e)
   100 
   101 #define DEBUG_CODE_SECTION(a)
   102 
   103 #endif
   104 
   105 
   106 } // namespace Swi
   107 
   108 #endif // __OCSP_LOG_H__