diff -r 000000000000 -r 09774dfdd46b qtinternetradio/irqlogger/inc/irqlogger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qtinternetradio/irqlogger/inc/irqlogger.h Mon Apr 19 14:01:53 2010 +0300 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2009 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 _IRQLOGGER_H_ +#define _IRQLOGGER_H_ + +#include +#include +#include "irqloggerexport.h" + +static const char* KLogMarker = "[QtInternetRadio]"; +static const char* KTraceOutputFile = "c:/logs/internetradio/iruilog.txt"; +#define FILTER_BY_LOGMARKER true + +#ifdef LOGGING_ENABLED + +#ifdef COMBINE_WITH_ENGINE_LOGGER + #define WRITELOG(msg) \ + { \ + QString tmpStr(msg); \ + SymbianLogger::writeLog(tmpStr); \ + } + #define INSTALL_MESSAGE_HANDLER +#else // COMBINE_WITH_ENGINE_LOGGER + + #define WRITELOG(msg) qDebug()< SomeFunction(int,const char*) +// <-- SomeFunction(int,const char*) +// <-- SomeFunction(int,const char*): Exception raised! +#define LOG_METHOD MethodLogger ___methodLogger( __PRETTY_FUNCTION__ ) + +// Logs function enter but does not log exit or leave. This is meant to be lighter than LOG_METHOD macro +#define LOG_METHOD_ENTER LOG_FORMAT( "<--> %s", __PRETTY_FUNCTION__ ) + + +// Assert macro for logging. If the condition is false, the expression is performed +// Example: +// LOG_ASSERT( thisMustBeTrue, LOG_FORMAT( "OMG! That was not true: %d", thisMustBeTrue ) ); +#define LOG_ASSERT(cond,expr) \ + { \ + if (!cond) { expr; } \ + } + +// Macro to log slot function caller by its class name. +#define LOG_SLOT_CALLER \ + { \ + QObject* caller = sender(); \ + if ( caller ) \ + { \ + LOG_FORMAT( "SLOT %s called by %s. Objectname: %s", __PRETTY_FUNCTION__, \ + caller->metaObject()->className(), STRING2CHAR( caller->objectName() ) ); \ + } else { \ + LOG_FORMAT( "SLOT %s called as regular function. ", __PRETTY_FUNCTION__ ); \ + } \ + } + +#else // LOGGING_ENABLED + #define LOG(string) + #define STRING2CHAR(qstring) + #define LOG_FORMAT(fmt,args...) + #define LOG_METHOD + #define LOG_METHOD_ENTER + #define LOG_ASSERT(cond,expr) + #define LOG_SLOT_CALLER + #define INSTALL_MESSAGE_HANDLER +#endif // LOGGING_ENABLED + + + + +// Class declaration +class IRQLOGGER_DLL_EXPORT SymbianLogger +{ +public: + static void writeLog( const QString& aMsg ); +}; + +// Class declaration +class IRQLOGGER_DLL_EXPORT MethodLogger +{ +public: + MethodLogger( const char* aFunction ); + ~MethodLogger(); + +private: + const char* iFunction; +}; + +// Class declaration +class IRQLOGGER_DLL_EXPORT FileLogger +{ +public: + FileLogger(const QString& aFileName, bool aFilterByMarker); + ~FileLogger(); +private: + void installMessageHandler( const QString& aFileName, bool aFilterByMarker ); + void uninstallMessageHandler(); + static void handleMessage( QtMsgType aType, const char* aMsg ); +}; + +// ============================================================================ +// SIGNAL/SLOT CONNECTION CHECKER +// ============================================================================ +IRQLOGGER_DLL_EXPORT bool connectAndTest( const QObject* aSender, const char* aSignal, + const QObject* aReceiver, const char* aMember, + Qt::ConnectionType aType = Qt::AutoConnection ); + +IRQLOGGER_DLL_EXPORT bool connectAndAssert( const QObject* aSender, const char* aSignal, + const QObject* aReceiver, const char* aMember, + Qt::ConnectionType aType = Qt::AutoConnection ); + +#endif // _IRQLOGGER_H_