|
1 /* |
|
2 * Copyright (c) 2002 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 * Class offers static utility functions for EMail. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "MailLog.h" |
|
24 |
|
25 #ifdef MAIL_ENABLE_LOGGING |
|
26 #include <flogger.h> |
|
27 #include <e32svr.h> |
|
28 #include <f32file.h> |
|
29 |
|
30 /// Folder where the log resides |
|
31 _LIT( KLogFolder, "EMail" ); |
|
32 |
|
33 /// The name of the log file |
|
34 _LIT( KLogFileName, "EMail.txt" ); |
|
35 |
|
36 /// The format in which the time is formatted in log |
|
37 _LIT( KLogTimeFormat, "%02d,%06d ;"); |
|
38 |
|
39 /// The length of the string produced by KLogTimeFormat |
|
40 const TInt KLogTimeFormatLength = 16; |
|
41 |
|
42 /// How many characters a log line can contain |
|
43 const TInt KLogLineLength = 256; |
|
44 |
|
45 #endif // MAIL_ENABLE_LOGGING |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 |
|
49 #ifdef MAIL_ENABLE_LOGGING |
|
50 // --------------------------------------------------------- |
|
51 // LogHeap() |
|
52 // |
|
53 // --------------------------------------------------------- |
|
54 void MailLog::LogHandleSize( RFile aFile ) |
|
55 { |
|
56 _LIT(KLOGHEAP, "MsgMail handle size: %d"); |
|
57 TInt size(0); |
|
58 aFile.Size( size ); |
|
59 Log(KLOGHEAP, size); |
|
60 } |
|
61 |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // LogHeap() |
|
65 // |
|
66 // --------------------------------------------------------- |
|
67 void MailLog::LogHeap() |
|
68 { |
|
69 _LIT(KLOGHEAP, "MsgMail heap used: %d @ %d"); |
|
70 TInt maxHeapSize(0); |
|
71 TInt usedHeap = User::Heap().AllocSize(maxHeapSize); |
|
72 Log(KLOGHEAP, usedHeap, maxHeapSize); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // Log() |
|
77 // |
|
78 // --------------------------------------------------------- |
|
79 void MailLog::Log( TRefByValue<const TDesC> aText, ... ) |
|
80 { |
|
81 VA_LIST args; |
|
82 VA_START( args, aText ); |
|
83 |
|
84 TBuf<KLogLineLength> buf; |
|
85 buf.FormatList( aText, args ); |
|
86 |
|
87 #ifdef MAIL_LOG_TO_FILE |
|
88 RFileLogger logger; |
|
89 TInt ret = logger.Connect(); |
|
90 if (ret==KErrNone) |
|
91 { |
|
92 logger.SetDateAndTime( EFalse,EFalse ); |
|
93 logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend ); |
|
94 TBuf<KLogTimeFormatLength> timeStamp; |
|
95 TTime now; |
|
96 now.HomeTime(); |
|
97 TDateTime dateTime; |
|
98 dateTime = now.DateTime(); |
|
99 timeStamp.Format( KLogTimeFormat, |
|
100 dateTime.Second(), dateTime.MicroSecond() ); |
|
101 buf.Insert( 0, timeStamp ); |
|
102 |
|
103 logger.Write(buf); |
|
104 } |
|
105 |
|
106 logger.Close(); |
|
107 |
|
108 #else |
|
109 RDebug::Print( buf ); |
|
110 #endif // MAIL_LOG_TO_FILE |
|
111 |
|
112 VA_END( args ); |
|
113 } |
|
114 |
|
115 #endif // MAIL_ENABLE_LOGGING |
|
116 |
|
117 // End of file |