|
1 /* |
|
2 * Copyright (c) 2001-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 the License "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: Definition of macros used for logging |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: tr1cfwln#7 % |
|
20 */ |
|
21 |
|
22 #ifndef WIFIPROTLOGGER_H_INCLUDED |
|
23 #define WIFIPROTLOGGER_H_INCLUDED |
|
24 |
|
25 // ========== INCLUDE FILES ================================ |
|
26 |
|
27 #include <eikenv.h> |
|
28 #include <flogger.h> |
|
29 |
|
30 #ifdef _DEBUG |
|
31 |
|
32 // Format string: enter function. |
|
33 _LIT( KCCDLGLogEnterFn, "-> %S" ); |
|
34 // Format string: leave function. |
|
35 _LIT( KCCDLGLogLeaveFn, "<- %S" ); |
|
36 // Format string: time. |
|
37 _LIT( KCCDLGLogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
38 |
|
39 // Logging directory. |
|
40 _LIT( KCCDLGLogDir, "wps" ); |
|
41 // Log file name. |
|
42 _LIT( KCCDLGLogFile, "wps.txt" ); |
|
43 _LIT( KCCDLGLogBanner, "****************\n\nWiFiProtectedSetupUi\n\n****************" ); |
|
44 _LIT( KCCDLGLogExit, "WiFiProtectedSetupUi: Exit" ); |
|
45 |
|
46 #define CLOG_CREATE {FCreate();} |
|
47 #define CLOG_DELETE {RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogExit);} |
|
48 #define CLOG_ENTERFN(a) {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogEnterFn, &temp);} |
|
49 #define CLOG_LEAVEFN(a) {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogLeaveFn, &temp);} |
|
50 #define CLOG_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, temp);} |
|
51 #define CLOG_WRITE_TIMESTAMP(a) {_LIT(temp, a); TTime time; time.HomeTime(); TBuf<256> buffer; time.FormatL( buffer, KCCDLGLogTimeFormatString ); buffer.Insert(0, temp); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, buffer); } |
|
52 #define CLOG_WRITEF FPrint |
|
53 |
|
54 // --------------------------------------------------------- |
|
55 // FPrint |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
59 { |
|
60 VA_LIST list; |
|
61 VA_START(list,aFmt); |
|
62 RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aFmt, list); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // FPrint |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 inline void FPrint(const TDesC& aDes) |
|
70 { |
|
71 RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aDes); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // FHex |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
79 { |
|
80 RFileLogger::HexDump(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // FHex |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 inline void FHex(const TDesC8& aDes) |
|
88 { |
|
89 FHex(aDes.Ptr(), aDes.Length()); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // FCreate |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 inline void FCreate() |
|
97 { |
|
98 TFileName path( _L( "c:\\logs\\" ) ); |
|
99 path.Append( KCCDLGLogDir ); |
|
100 path.Append( _L( "\\" ) ); |
|
101 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
102 fs.MkDirAll( path ); |
|
103 RFileLogger::WriteFormat( KCCDLGLogDir, KCCDLGLogFile, |
|
104 EFileLoggingModeAppend, KCCDLGLogBanner ); |
|
105 } |
|
106 |
|
107 #else // ! _DEBUG |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // FPrint |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { }; |
|
114 |
|
115 #define CLOG_CREATE |
|
116 #define CLOG_DELETE |
|
117 #define CLOG_ENTERFN(a) |
|
118 #define CLOG_LEAVEFN(a) |
|
119 #define CLOG_WRITE(a) |
|
120 #define CLOG_WRITEF 1 ? ((void)0) : FPrint |
|
121 #define CLOG_WRITE_TIMESTAMP(a) |
|
122 |
|
123 #endif // _DEBUG |
|
124 |
|
125 |
|
126 #endif // WIFIPROTLOGGER_H_INCLUDED |