20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Definitions of logging macros for Analyze Tool S60 modules.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef __ATLOG_H__
|
|
19 |
#define __ATLOG_H__
|
|
20 |
|
|
21 |
#ifdef _DEBUG
|
|
22 |
//To enable/disable logging uncomment/comment the next line
|
|
23 |
// #define LOGGING_ENABLED //Enable logging
|
|
24 |
//Uncomment next to enable logging only LOGSTR1 lines
|
|
25 |
// #define LOGGING_ENABLED_FAST //Logging only function names
|
|
26 |
|
|
27 |
//Disable next to use file logging
|
|
28 |
#define USE_RDEBUG
|
|
29 |
#endif
|
|
30 |
|
|
31 |
//Do not alter the code below this
|
|
32 |
|
|
33 |
#ifdef __KERNEL_MODE__
|
|
34 |
|
|
35 |
#ifdef LOGGING_ENABLED
|
|
36 |
#include <kernel.h>
|
|
37 |
#define LOGSTR1( AAA ) { Kern::Printf( AAA ); }
|
|
38 |
#define LOGSTR2( AAA, BBB ) { Kern::Printf( AAA, BBB ); }
|
|
39 |
#else
|
|
40 |
#define LOGSTR1( AAA )
|
|
41 |
#define LOGSTR2( AAA, BBB )
|
|
42 |
#endif
|
|
43 |
|
|
44 |
#else // #ifdef __KERNEL_MODE__
|
|
45 |
|
|
46 |
#ifdef LOGGING_ENABLED
|
|
47 |
|
|
48 |
// INCLUDES
|
|
49 |
#include <flogger.h>
|
|
50 |
#ifdef USE_RDEBUG
|
|
51 |
#include <e32svr.h>
|
|
52 |
#endif
|
|
53 |
|
|
54 |
// CONSTANTS
|
|
55 |
_LIT( KAtLoggingFolder, "atlog" );
|
|
56 |
_LIT( KAtLoggingFile , "LOG.TXT" );
|
|
57 |
#define ONE_SPACE_MARGIN _S(" ")
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------------
|
|
60 |
// Internal MACROS. Do not call these directly, use the External MACROS instead
|
|
61 |
// ---------------------------------------------------------------------------------
|
|
62 |
|
|
63 |
#ifdef LOGGING_ENABLED_FAST
|
|
64 |
|
|
65 |
#ifdef USE_RDEBUG
|
|
66 |
#define INTERNAL_LOGSTR1( AAA ) { _LIT( logdes, AAA ); RDebug::Print( logdes() ); }
|
|
67 |
#else // RFileLogger is used
|
|
68 |
#define INTERNAL_LOGSTR1( AAA ) { _LIT( logdes, AAA ); RFileLogger::Write( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, logdes() ); }
|
|
69 |
#endif // USE_RDEBUG
|
|
70 |
#define INTERNAL_LOGSTR2( AAA, BBB )
|
|
71 |
#define INTERNAL_LOGSTR3( AAA, BBB, CCC )
|
|
72 |
#define INTERNAL_LOGMEM
|
|
73 |
#define INTERNAL_LOG( AAA )
|
|
74 |
|
|
75 |
#else
|
|
76 |
|
|
77 |
#ifdef USE_RDEBUG
|
|
78 |
#define INTERNAL_LOGDESC8( AAA ) { TBuf<100> tmp; if( sizeof( AAA ) < 100 ) tmp.Copy( AAA ); RDebug::Print( tmp );}
|
|
79 |
#define INTERNAL_LOGSTR1( AAA ) { _LIT( logdes, AAA ); RDebug::Print( logdes() ); }
|
|
80 |
#define INTERNAL_LOGSTR2( AAA, BBB ) { _LIT( logdes, AAA ); RDebug::Print( TRefByValue<const TDesC>( logdes()), BBB ); }
|
|
81 |
#define INTERNAL_LOGSTR3( AAA, BBB, CCC ) { _LIT( logdes, AAA ); RDebug::Print( TRefByValue<const TDesC>(logdes()), BBB, CCC ); }
|
|
82 |
#define INTERNAL_LOGMEM { _LIT( logdes, "Heap size: %i" ); TBuf<50> buf; TInt a; User::AllocSize( a ); buf.Format( logdes, a ); RDebug::Print( buf ); }
|
|
83 |
#define INTERNAL_LOG( AAA ) AAA
|
|
84 |
#else // RFileLogger is used
|
|
85 |
#define INTERNAL_LOGSTR1( AAA ) { _LIT( logdes, AAA ); RFileLogger::Write( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, logdes() ); }
|
|
86 |
#define INTERNAL_LOGSTR2( AAA, BBB ) { _LIT( logdes, AAA ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>( logdes()), BBB ); }
|
|
87 |
#define INTERNAL_LOGSTR3( AAA, BBB, CCC) { _LIT( logdes, AAA ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>(logdes()), BBB, CCC ); }
|
|
88 |
#define INTERNAL_LOGMEM { _LIT( logdes, "Heap size: %i" ); TMemoryInfoV1Buf info; UserHal::MemoryInfo(info); TInt freeMemory = info().iFreeRamInBytes; TBuf<50> buf; buf.Format( logdes, freeMemory ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, buf ); }
|
|
89 |
#define INTERNAL_LOG( AAA ) AAA
|
|
90 |
#endif // USE_RDEBUG
|
|
91 |
|
|
92 |
#endif
|
|
93 |
|
|
94 |
#else
|
|
95 |
|
|
96 |
#define INTERNAL_LOGSTR1( AAA )
|
|
97 |
#define INTERNAL_LOGSTR2( AAA, BBB )
|
|
98 |
#define INTERNAL_LOGSTR3( AAA, BBB, CCC )
|
|
99 |
#define INTERNAL_LOGMEM
|
|
100 |
#define INTERNAL_LOG( AAA )
|
|
101 |
|
|
102 |
#endif
|
|
103 |
|
|
104 |
// ---------------------------------------------------------------------------------
|
|
105 |
// External MACROS. Use these in code
|
|
106 |
// ---------------------------------------------------------------------------------
|
|
107 |
// Logging of string
|
|
108 |
// i.e.: LOGSTR1( "Whoo-haa!" );
|
|
109 |
#define LOGSTR1( AAA ) { INTERNAL_LOGSTR1( AAA ); }
|
|
110 |
|
|
111 |
// Logging of string + integer value
|
|
112 |
// i.e.: LOGSTR2( "CHttpd status %i:", iStatus );
|
|
113 |
#define LOGSTR2( AAA, BBB ) { INTERNAL_LOGSTR2( AAA, BBB ); }
|
|
114 |
|
|
115 |
// Logging of descriptor + 2 integers
|
|
116 |
// i.e.: LOGSTR3( "Jippii %i %i", val1, val2 );
|
|
117 |
#define LOGSTR3( AAA, BBB, CCC ) { INTERNAL_LOGSTR3( AAA, BBB, CCC ); }
|
|
118 |
|
|
119 |
// Log heap size
|
|
120 |
#define LOGMEM { INTERNAL_LOGMEM }
|
|
121 |
|
|
122 |
// Logging variable operations
|
|
123 |
#define LOG( AAA ) INTERNAL_LOG( AAA )
|
|
124 |
|
|
125 |
#endif // #ifdef __KERNEL_MODE__
|
|
126 |
|
|
127 |
#endif // __ATLOG_H__
|
|
128 |
// End of File
|