locationmapnavfw/library/inc/mndebug.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:24:21 +0100
branchRCL_3
changeset 45 6b6920c56e2f
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:  Debug macros
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*/
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
#ifndef MN_DEBUG_H
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#define MN_DEBUG_H
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#ifdef _DEBUG
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <e32base.h>
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
inline void Panic( TInt aReason )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
    {
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
    _LIT( KPanicCategory, "MnLibraryDebug" );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
    User::Panic( KPanicCategory, aReason );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
    }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
#include <e32svr.h>
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
#include <e32std.h>
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
#include <f32file.h>
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
#include <flogger.h>
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
_LIT(KLogFile, "mnlog.txt");
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
_LIT(KLogDirFullName, "c:\\logs\\");
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
_LIT(KLogDir, "mn");
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
inline void Prefix( TDes& aMessage )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
    {
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
    RProcess process;
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
    _LIT( KPrefix, "[MnLibrary/%ld]: ");
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
    aMessage.Format( KPrefix, process.Id().Id() );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
    }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
inline void Log( TRefByValue<const TDesC> aFmt, ... )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
    {
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
    // coverity[var_decl : FALSE]
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
    VA_LIST list;
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
    // coverity[ uninit_use_in_call : FALSE]
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
    VA_START( list, aFmt );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
    HBufC* buf = HBufC::New(512);
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
    if ( buf )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
    	{
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
    	TPtr ptr( buf->Des() );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
	    Prefix( ptr );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
	    // coverity[ uninit_use_in_call : FALSE]
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
	    ptr.AppendFormatList( aFmt, list );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
	
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
	    RDebug::RawPrint( ptr );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
	    RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, ptr );
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
	    delete buf;
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    	}
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
#define LOG( a )             { Log( _L( a ) ); }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
#define LOG1( a, b )         { Log( _L( a ), b ); }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
#define LOG2( a, b, c )      { Log( _L( a ), b, c ); }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
#define LOG3( a, b, c, d )   { Log( _L( a ), b, c, d ); }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
#define LOG4( a, b, c, d, e )   { Log( _L( a ), b, c, d, e ); }
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
#else // _DEBUG
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
// Release version - no logging
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
#define LOG( a)
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
#define LOG1( a, b )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
#define LOG2( a, b, c)
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
#define LOG3( a, b, c, d)
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
#define LOG4( a, b, c, d, e )
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
#endif // _DEBUG
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
#endif // MN_DEBUG_H
6b6920c56e2f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88