contentpublishingsrv/contentpublishingutils/pluginvalidator/inc/chplugindebug.h
branchRCL_3
changeset 31 8baec10861af
equal deleted inserted replaced
30:a5a39a295112 31:8baec10861af
       
     1 /*
       
     2 * Copyright (c) 2006-2006 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 "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 *
       
    16 */
       
    17 #ifndef CPSDEBUG_H
       
    18 #define CPSDEBUG_H
       
    19 
       
    20 // INCLUDES
       
    21 #include <e32std.h>
       
    22 #include <flogger.h>
       
    23 
       
    24 // Maximum formatted size resulting from a single DEBUG* call
       
    25 #ifndef MAX_DEBUG_STRING_LENGTH
       
    26 #define MAX_DEBUG_STRING_LENGTH 4096
       
    27 #endif
       
    28 
       
    29 #ifdef _DEBUG
       
    30 // ----------------------------------------------------------
       
    31 // Debug file - debug output is disabled if the parent dir does not exist
       
    32 _LIT(KPerformanceLogDir, "cps");
       
    33 _LIT(KPerformanceLogFile, "pluginvalidator_perf.txt");
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 static void DoOutputPerf(TDesC8& aData)
       
    39     {
       
    40     RFileLogger::Write( KPerformanceLogDir,
       
    41                        KPerformanceLogFile,
       
    42                        EFileLoggingModeAppend,
       
    43                        aData );
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 static void DebugStringNarrowPerfL(const char* aFmt, ...)
       
    50     {
       
    51     VA_LIST args;
       
    52     VA_START(args, aFmt);
       
    53 
       
    54     TPtrC8 fmt(reinterpret_cast<const unsigned char *>(aFmt));
       
    55     HBufC8* buf = HBufC8::NewLC(MAX_DEBUG_STRING_LENGTH);
       
    56     buf->Des().FormatList(fmt, args);
       
    57     buf->Des().Append('\n');
       
    58 
       
    59     TTime timestamp;
       
    60     timestamp.HomeTime();
       
    61 
       
    62     TBuf<64> dateTimeString;
       
    63     TBuf8<64> dateTimeString8;
       
    64 
       
    65     _LIT(KTimeString, "%:0%J%:1%T%:2%S%.%*C4%:3");
       
    66     timestamp.FormatL(dateTimeString, KTimeString);
       
    67     dateTimeString8.Copy( dateTimeString );
       
    68     buf->Des().Insert( 0, _L8(" -> ") );
       
    69     buf->Des().Insert( 0, dateTimeString8 );
       
    70 
       
    71     DoOutputPerf(*buf);
       
    72     CleanupStack::PopAndDestroy(buf);
       
    73 
       
    74     VA_END(args);
       
    75     }
       
    76 
       
    77 #define CPSPERF(x) TRAP_IGNORE( DebugStringNarrowPerfL x )
       
    78 #else
       
    79 #define CPSPERF(x)
       
    80 #endif
       
    81 
       
    82 #endif // CPSDEBUG_H