sl@0: // Copyright (c) 2007-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 "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: // General inline utility and logging functions for use with DirectGDI. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @prototype sl@0: */ sl@0: sl@0: #ifndef DIRECTGDIPANICS_INL sl@0: #define DIRECTGDIPANICS_INL sl@0: sl@0: #include sl@0: #include sl@0: sl@0: _LIT(KDGDILogFormat, "File %S +%i: %S"); sl@0: _LIT(KDGDINonConditionalPanicFormat, "Panic: %S %i."); sl@0: _LIT(KDGDIConditionalPanicFormat, "Panic: %S %i, assert \"%S\" failed."); sl@0: sl@0: namespace DirectGdi sl@0: { sl@0: sl@0: /** sl@0: Helper function used by the GRAPHICS_LOG_ALWAYS and GRAPHICS_LOGD_ALWAYS macros. sl@0: */ sl@0: inline void Log(const TDesC& aFileName, TInt aLine, const TDesC& aLogMessage) sl@0: { sl@0: TBuf<256> buf; sl@0: buf.Format(KDGDILogFormat, &aFileName, aLine, &aLogMessage); sl@0: RDebug::Print(buf); sl@0: } sl@0: sl@0: /** sl@0: Helper function used by GRAPHICS_ASSERT_ALWAYS and GRAPHICS_PANIC_ALWAYS macros sl@0: which allows a panic category and code to be logged. sl@0: */ sl@0: inline void PanicWithDebugLog ( sl@0: const TDesC& aPanicCategory, sl@0: TInt aPanicCode, sl@0: const TDesC& aFileName, sl@0: TInt aLine, sl@0: const TDesC* aCondition) sl@0: { sl@0: TBuf<256> message; sl@0: sl@0: if (aCondition) sl@0: { sl@0: message.Format(KDGDIConditionalPanicFormat, &aPanicCategory, aPanicCode, aCondition); sl@0: } sl@0: else sl@0: { sl@0: message.Format(KDGDINonConditionalPanicFormat, &aPanicCategory, aPanicCode); sl@0: } sl@0: sl@0: Log(aFileName, aLine, message); sl@0: sl@0: User::Panic(aPanicCategory, aPanicCode); sl@0: } sl@0: } sl@0: sl@0: #endif // DIRECTGDIPANICS_INL sl@0: sl@0: