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