|
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: Offers logging facility through flogger |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef SATLOG_H |
|
20 #define SATLOG_H |
|
21 |
|
22 // LOGGING LEVELS |
|
23 const TInt SIMPLE( 1 ); |
|
24 const TInt NORMAL( 2 ); |
|
25 const TInt DETAILED( 3 ); |
|
26 |
|
27 #include <flogger.h> |
|
28 #include <e32svr.h> // For RDebug |
|
29 |
|
30 #ifdef ENABLE_SAT_LOGGING |
|
31 |
|
32 // |
|
33 // DEFINE THE LOGGING LEVEL HERE: SIMPLE, NORMAL, DETAILED |
|
34 // |
|
35 #define LOGGING_LEVEL NORMAL |
|
36 |
|
37 // CONSTANTS |
|
38 _LIT( KLogDir, "sat" ); |
|
39 _LIT( KLogFile, "sat.txt" ); |
|
40 |
|
41 // This warning is disabled: conditinal expression is constant. |
|
42 |
|
43 // |
|
44 // USE THIS MACRO FOR LOGGING. THE LEVEL OF LOGGING CAN BE |
|
45 // SIMPLE, NORMAL, DETAILED |
|
46 // |
|
47 #ifdef LOG |
|
48 #undef LOG |
|
49 #endif |
|
50 |
|
51 #define LOG( LEVEL, TEXT ) \ |
|
52 { \ |
|
53 if ( LEVEL <= LOGGING_LEVEL ) \ |
|
54 { \ |
|
55 _LIT( KText, TEXT ); \ |
|
56 RFileLogger::Write( \ |
|
57 KLogDir, \ |
|
58 KLogFile, \ |
|
59 EFileLoggingModeAppend, \ |
|
60 KText ); \ |
|
61 RDebug::Print( KText ); \ |
|
62 } \ |
|
63 } |
|
64 |
|
65 #ifdef LOG2 |
|
66 #undef LOG2 |
|
67 #endif |
|
68 |
|
69 #define LOG2( LEVEL, TEXT, VARIABLE ) \ |
|
70 { \ |
|
71 if ( LEVEL <= LOGGING_LEVEL ) \ |
|
72 { \ |
|
73 _LIT( KText, TEXT ); \ |
|
74 RFileLogger::WriteFormat( \ |
|
75 KLogDir, \ |
|
76 KLogFile, \ |
|
77 EFileLoggingModeAppend, \ |
|
78 TRefByValue<const TDesC>( KText() ), VARIABLE ); \ |
|
79 RDebug::Print( KText, VARIABLE ); \ |
|
80 } \ |
|
81 } |
|
82 |
|
83 #ifdef LOG3 |
|
84 #undef LOG3 |
|
85 #endif |
|
86 |
|
87 #define LOG3( LEVEL, TEXT, VARIABLE1, VARIABLE2 ) \ |
|
88 { \ |
|
89 if ( LEVEL <= LOGGING_LEVEL ) \ |
|
90 { \ |
|
91 _LIT( KText, TEXT ); \ |
|
92 RFileLogger::WriteFormat( \ |
|
93 KLogDir, \ |
|
94 KLogFile, \ |
|
95 EFileLoggingModeAppend, \ |
|
96 TRefByValue<const TDesC>( KText() ), VARIABLE1, VARIABLE2 ); \ |
|
97 RDebug::Print( KText, VARIABLE1, VARIABLE2 ); \ |
|
98 } \ |
|
99 } |
|
100 |
|
101 #else // ENABLE_SAT_LOGGING |
|
102 |
|
103 #define LOG( LEVEL, TEXT ) |
|
104 |
|
105 #define LOG2( LEVEL, TEXT, VARIABLE1 ) |
|
106 |
|
107 #define LOG3( LEVEL, TEXT, VARIABLE1, VARIABLE2 ) |
|
108 |
|
109 #endif // ENABLE_SAT_LOGGING |
|
110 |
|
111 #endif // SATLOG_H |