bluetooth/btlogger/generic/public/logger.h
changeset 51 20ac952a623c
parent 0 29b1cd4cb562
equal deleted inserted replaced
48:22de2e391156 51:20ac952a623c
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    57 _LIT8(KDefaultLogFile, "BT");
    57 _LIT8(KDefaultLogFile, "BT");
    58 
    58 
    59 #ifdef __FLOG_ACTIVE
    59 #ifdef __FLOG_ACTIVE
    60 #define CONNECT_LOGGER					static_cast<void>(CBtLog::Connect());
    60 #define CONNECT_LOGGER					static_cast<void>(CBtLog::Connect());
    61 #define CLOSE_LOGGER					CBtLog::Close();
    61 #define CLOSE_LOGGER					CBtLog::Close();
       
    62 #define DEFINE_LOG_COMPONENT(a)			_LIT8(KLogComponent, a);
    62 #define LEAVEIFERRORL(a)				VerboseLeaveIfErrorL(KLogComponent, __FILE__, __LINE__, a)
    63 #define LEAVEIFERRORL(a)				VerboseLeaveIfErrorL(KLogComponent, __FILE__, __LINE__, a)
    63 #define LEAVEL(a)						VerboseLeaveL(KLogComponent, __FILE__, __LINE__, a)
    64 #define LEAVEL(a)						VerboseLeaveL(KLogComponent, __FILE__, __LINE__, a)
    64 #define PANIC(CAT, CODE) 				VerbosePanic(KLogComponent, __FILE__, __LINE__, CODE, (TText8*)#CODE, CAT)
    65 #define PANIC(CAT, CODE) 				VerbosePanic(KLogComponent, __FILE__, __LINE__, CODE, (TText8*)#CODE, CAT)
    65 #define PANIC_MSG(msg, cat, code)		VerboseMsgPanic(KLogComponent, __FILE__, __LINE__, msg, cat, code);
    66 #define PANIC_MSG(msg, cat, code)		VerboseMsgPanic(KLogComponent, __FILE__, __LINE__, msg, cat, code);
    66 #define FLOG(a)							CBtLog::Write(KDefaultLogFile, a);
    67 #define FLOG(a)							CBtLog::Write(KDefaultLogFile, a);
    79 #define DUMPFRAME(text)					{LOG(text);TInt _lctr = this->Length();if(_lctr){for(TInt _ictr = 0; _ictr < _lctr; ++_ictr){LOG2(_L8("....[%d] = %02x"),_ictr,this->First()->Ptr()[_ictr]);}}}
    80 #define DUMPFRAME(text)					{LOG(text);TInt _lctr = this->Length();if(_lctr){for(TInt _ictr = 0; _ictr < _lctr; ++_ictr){LOG2(_L8("....[%d] = %02x"),_ictr,this->First()->Ptr()[_ictr]);}}}
    80 #define LOG_BT(aa, bb)					{TBuf8<20> addr1; addr1.Format(_L8("%02x:%02x:%02x:%02x:%02x:%02x"), bb[0], bb[1], bb[2], bb[3], bb[4], bb[5]); LOG1(aa, &addr1); }
    81 #define LOG_BT(aa, bb)					{TBuf8<20> addr1; addr1.Format(_L8("%02x:%02x:%02x:%02x:%02x:%02x"), bb[0], bb[1], bb[2], bb[3], bb[4], bb[5]); LOG1(aa, &addr1); }
    81 #else
    82 #else
    82 #define CONNECT_LOGGER
    83 #define CONNECT_LOGGER
    83 #define CLOSE_LOGGER
    84 #define CLOSE_LOGGER
       
    85 #define DEFINE_LOG_COMPONENT(a)
    84 #define LEAVEIFERRORL(a)				static_cast<void>(User::LeaveIfError(a))
    86 #define LEAVEIFERRORL(a)				static_cast<void>(User::LeaveIfError(a))
    85 #define LEAVEL(a)						User::Leave(a)
    87 #define LEAVEL(a)						User::Leave(a)
    86 #define PANIC(CAT, CODE) 				User::Panic(CAT, CODE)
    88 #define PANIC(CAT, CODE) 				User::Panic(CAT, CODE)
    87 #define PANIC_MSG(msg, cat, code)		msg.Panic(cat, code);
    89 #define PANIC_MSG(msg, cat, code)		msg.Panic(cat, code);
    88 #define FLOG(a)
    90 #define FLOG(a)
   139 // category is 10 characters long or less, so that the whole thing is legible 
   141 // category is 10 characters long or less, so that the whole thing is legible 
   140 // when it appears to users (panic categories are truncated to 16 characters).
   142 // when it appears to users (panic categories are truncated to 16 characters).
   141 
   143 
   142 // We want a 10-character string (but allow for the NULL terminator).
   144 // We want a 10-character string (but allow for the NULL terminator).
   143 #define PANICCATEGORY(aaa) __ASSERT_COMPILE(sizeof(L##aaa)/2 <= 11); _LIT(KMungedPanicCat, aaa) 
   145 #define PANICCATEGORY(aaa) __ASSERT_COMPILE(sizeof(L##aaa)/2 <= 11); _LIT(KMungedPanicCat, aaa) 
       
   146 #define PANIC_CATEGORY(aaa) PANICCATEGORY(aaa);
       
   147 
       
   148 #define DEBUG_PANIC_CATEGORY(aaa) __DEBUG_ONLY(PANICCATEGORY(aaa);)
   144 
   149 
   145 // A handy panic-self macro- the category is whatever has been declared with 
   150 // A handy panic-self macro- the category is whatever has been declared with 
   146 // BTPANICCATEGORY, with " line#" appended. The panic code is the line number. 
   151 // BTPANICCATEGORY, with " line#" appended. The panic code is the line number. 
   147 #define PANIC_LINENUM \
   152 #define PANIC_LINENUM \
   148 	{ \
   153 	{ \