45
|
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 |
// coverity[var_decl : FALSE]
|
|
51 |
VA_LIST list;
|
|
52 |
// coverity[ uninit_use_in_call : FALSE]
|
|
53 |
VA_START( list, aFmt );
|
|
54 |
|
|
55 |
HBufC* buf = HBufC::New(512);
|
|
56 |
if ( buf )
|
|
57 |
{
|
|
58 |
TPtr ptr( buf->Des() );
|
|
59 |
Prefix( ptr );
|
|
60 |
// coverity[ uninit_use_in_call : FALSE]
|
|
61 |
ptr.AppendFormatList( aFmt, list );
|
|
62 |
|
|
63 |
RDebug::RawPrint( ptr );
|
|
64 |
RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, ptr );
|
|
65 |
|
|
66 |
delete buf;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
#define LOG( a ) { Log( _L( a ) ); }
|
|
71 |
#define LOG1( a, b ) { Log( _L( a ), b ); }
|
|
72 |
#define LOG2( a, b, c ) { Log( _L( a ), b, c ); }
|
|
73 |
#define LOG3( a, b, c, d ) { Log( _L( a ), b, c, d ); }
|
|
74 |
#define LOG4( a, b, c, d, e ) { Log( _L( a ), b, c, d, e ); }
|
|
75 |
|
|
76 |
#else // _DEBUG
|
|
77 |
|
|
78 |
// Release version - no logging
|
|
79 |
#define LOG( a)
|
|
80 |
#define LOG1( a, b )
|
|
81 |
#define LOG2( a, b, c)
|
|
82 |
#define LOG3( a, b, c, d)
|
|
83 |
#define LOG4( a, b, c, d, e )
|
|
84 |
|
|
85 |
#endif // _DEBUG
|
|
86 |
|
|
87 |
#endif // MN_DEBUG_H
|
|
88 |
|