usbservices_plat/usb_personality_plugin_api/tsrc/usbpersonalitypluginapitest/inc/testdebug.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 10:54:11 +0300
branchRCL_3
changeset 22 5b2a402e96ac
permissions -rw-r--r--
Revision: 201031 Kit: 201033

/*
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

#ifndef TESTDEBUG_H_
#define TESTDEBUG_H_

//  INCLUDES
#include <e32debug.h>
#include <e32def.h>

// CONSTANTS
_LIT8(KStifTestPrefix8, "[STIF_LOG] ");
_LIT( KStifTestPrefix, "[STIF_LOG] ");
_LIT8( KStifEntryPrefix8, ">>> %S" );
_LIT8( KStifExitPrefix8, "<<< %S" );

const TInt KMaxLogLineLength = 512;
typedef TBuf8< KMaxLogLineLength > TLogBuf8;
typedef TBuf16< KMaxLogLineLength > TLogBuf16;

// CLASS DECLARATION
NONSHARABLE_CLASS( TTestLogger )
    {
public:
    static inline TLogBuf16 CreateLogBuf( TRefByValue<const TDesC8> aFmt, ... );
    static inline TLogBuf16 CreateLogBuf( TRefByValue<const TDesC16> aFmt, ... );
    static inline void Trace( CStifLogger& aLog, TLogBuf16 aLogBuf );
    };

// MACROS
#define TRACE( p ) {\
        TLogBuf16 buf = TTestLogger::CreateLogBuf( _L( p ) );\
        TTestLogger::Trace( *iLog, buf );\
        }
#define TRACE_INFO( p, args... ) {\
        TLogBuf16 buf = TTestLogger::CreateLogBuf( _L( p ), args );\
        TTestLogger::Trace( *iLog, buf );\
        }
#define TRACE_FUNC_ENTRY {\
        TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ );\
        TLogBuf16 buf = TTestLogger::CreateLogBuf( KStifEntryPrefix8, &ptr8 );\
        TTestLogger::Trace( *iLog, buf );\
        }
#define TRACE_FUNC_EXIT {\
        TPtrC8 ptr8( ( TUint8* ) __FUNCTION__ );\
        TLogBuf16 buf = TTestLogger::CreateLogBuf( KStifExitPrefix8, &ptr8 );\
        TTestLogger::Trace( *iLog, buf );\
        }

#include "testdebug.inl"

#endif /* TESTDEBUG_H_ */