locationmapnavfw/library/inc/mndebug.h
changeset 0 667063e416a2
child 7 19bff11d6c18
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Debug macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MN_DEBUG_H
       
    20 #define MN_DEBUG_H
       
    21 
       
    22 #ifdef _DEBUG
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 inline void Panic( TInt aReason )
       
    27     {
       
    28     _LIT( KPanicCategory, "MnLibraryDebug" );
       
    29     User::Panic( KPanicCategory, aReason );
       
    30     }
       
    31 
       
    32 #include <e32svr.h>
       
    33 #include <e32std.h>
       
    34 #include <f32file.h>
       
    35 #include <flogger.h>
       
    36 
       
    37 _LIT(KLogFile, "mnlog.txt");
       
    38 _LIT(KLogDirFullName, "c:\\logs\\");
       
    39 _LIT(KLogDir, "mn");
       
    40 
       
    41 inline void Prefix( TDes& aMessage )
       
    42     {
       
    43     RProcess process;
       
    44     _LIT( KPrefix, "[MnLibrary/%ld]: ");
       
    45     aMessage.Format( KPrefix, process.Id().Id() );
       
    46     }
       
    47 
       
    48 inline void Log( TRefByValue<const TDesC> aFmt, ... )
       
    49     {
       
    50     VA_LIST list;
       
    51     VA_START( list, aFmt );
       
    52 
       
    53     HBufC* buf = HBufC::New(512);
       
    54     if ( buf )
       
    55     	{
       
    56     	TPtr ptr( buf->Des() );
       
    57 	    Prefix( ptr );
       
    58 	    ptr.AppendFormatList( aFmt, list );
       
    59 	
       
    60 	    RDebug::RawPrint( ptr );
       
    61 	    RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, ptr );
       
    62 
       
    63 	    delete buf;
       
    64     	}
       
    65     }
       
    66 
       
    67 #define LOG( a )             { Log( _L( a ) ); }
       
    68 #define LOG1( a, b )         { Log( _L( a ), b ); }
       
    69 #define LOG2( a, b, c )      { Log( _L( a ), b, c ); }
       
    70 #define LOG3( a, b, c, d )   { Log( _L( a ), b, c, d ); }
       
    71 #define LOG4( a, b, c, d, e )   { Log( _L( a ), b, c, d, e ); }
       
    72 
       
    73 #else // _DEBUG
       
    74 
       
    75 // Release version - no logging
       
    76 #define LOG( a)
       
    77 #define LOG1( a, b )
       
    78 #define LOG2( a, b, c)
       
    79 #define LOG3( a, b, c, d)
       
    80 #define LOG4( a, b, c, d, e )
       
    81 
       
    82 #endif // _DEBUG
       
    83 
       
    84 #endif // MN_DEBUG_H
       
    85