|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CONNECTIONDIALOGSLOGGER_H_INCLUDED |
|
21 #define CONNECTIONDIALOGSLOGGER_H_INCLUDED |
|
22 |
|
23 // ========== INCLUDE FILES ================================ |
|
24 |
|
25 #include <eikenv.h> |
|
26 #include <flogger.h> |
|
27 |
|
28 |
|
29 #ifdef _DEBUG |
|
30 |
|
31 // Format string: enter function. |
|
32 _LIT( KCCDLGLogEnterFn, "-> %S" ); |
|
33 // Format string: leave function. |
|
34 _LIT( KCCDLGLogLeaveFn, "<- %S" ); |
|
35 // Format string: time. |
|
36 _LIT( KCCDLGLogTimeFormatString, "%H:%T:%S:%*C2" ); |
|
37 |
|
38 // Logging directory. |
|
39 _LIT( KCCDLGLogDir, "ConnectionDialogs" ); |
|
40 // Log file name. |
|
41 _LIT( KCCDLGLogFile, "ConnectionDialogs.txt" ); |
|
42 _LIT( KCCDLGLogBanner, "****************\n\nConnectionDialogs\n\n****************" ); |
|
43 _LIT( KCCDLGLogExit, "ConnectionDialogs: Exit" ); |
|
44 |
|
45 #define CLOG_CREATE {FCreate();} |
|
46 #define CLOG_DELETE {RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogExit);} |
|
47 #define CLOG_ENTERFN(a) {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogEnterFn, &temp);} |
|
48 #define CLOG_LEAVEFN(a) {_LIT(temp, a); RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, KCCDLGLogLeaveFn, &temp);} |
|
49 #define CLOG_WRITE(a) {_LIT(temp, a); RFileLogger::Write(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, temp);} |
|
50 #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); } |
|
51 #define CLOG_WRITEF FPrint |
|
52 |
|
53 |
|
54 inline void FPrint(const TRefByValue<const TDesC> aFmt, ...) |
|
55 { |
|
56 VA_LIST list; |
|
57 VA_START(list,aFmt); |
|
58 RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aFmt, list); |
|
59 } |
|
60 |
|
61 inline void FPrint(const TDesC& aDes) |
|
62 { |
|
63 RFileLogger::WriteFormat(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, aDes); |
|
64 } |
|
65 |
|
66 inline void FHex(const TUint8* aPtr, TInt aLen) |
|
67 { |
|
68 RFileLogger::HexDump(KCCDLGLogDir, KCCDLGLogFile, EFileLoggingModeAppend, 0, 0, aPtr, aLen); |
|
69 } |
|
70 |
|
71 inline void FHex(const TDesC8& aDes) |
|
72 { |
|
73 FHex(aDes.Ptr(), aDes.Length()); |
|
74 } |
|
75 |
|
76 inline void FCreate() |
|
77 { |
|
78 TFileName path( _L( "c:\\logs\\" ) ); |
|
79 path.Append( KCCDLGLogDir ); |
|
80 path.Append( _L( "\\" ) ); |
|
81 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
82 fs.MkDirAll( path ); |
|
83 RFileLogger::WriteFormat( KCCDLGLogDir, KCCDLGLogFile, |
|
84 EFileLoggingModeAppend, KCCDLGLogBanner ); |
|
85 } |
|
86 |
|
87 #else // ! _DEBUG |
|
88 |
|
89 inline void FPrint(const TRefByValue<const TDesC> /*aFmt*/, ...) { }; |
|
90 |
|
91 #define CLOG_CREATE |
|
92 #define CLOG_DELETE |
|
93 #define CLOG_ENTERFN(a) |
|
94 #define CLOG_LEAVEFN(a) |
|
95 #define CLOG_WRITE(a) |
|
96 #define CLOG_WRITEF 1 ? ((void)0) : FPrint |
|
97 #define CLOG_WRITE_TIMESTAMP(a) |
|
98 |
|
99 #endif // _DEBUG |
|
100 |
|
101 |
|
102 #endif // CONNDLGLOGGER_H_INCLUDED |