|
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: Class offers static utility functions for CWmlBMSubItem. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <e32svr.h> |
|
24 #include "CWPLog.h" |
|
25 |
|
26 |
|
27 #ifdef ENABLE_LOGGING |
|
28 #include <flogger.h> |
|
29 |
|
30 /// Folder where the WMLBC log resides |
|
31 _LIT( KLogFolder, "ringbc" ); |
|
32 |
|
33 /// The name of the log file |
|
34 _LIT( KLogFileName, "ringbc.txt" ); |
|
35 |
|
36 /// The format in which the time is formatted in log |
|
37 _LIT( KLogTimeFormat, "%02d.%02d:%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 // ENABLE_LOGGING |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 |
|
49 #ifdef ENABLE_LOGGING |
|
50 // --------------------------------------------------------- |
|
51 // Log() |
|
52 // |
|
53 // --------------------------------------------------------- |
|
54 void Log::DoLog( TRefByValue<const TDesC> aText, ... ) |
|
55 { |
|
56 VA_LIST args; |
|
57 VA_START( args, aText ); |
|
58 |
|
59 TBuf<KLogLineLength> buf; |
|
60 buf.FormatList( aText, args ); |
|
61 |
|
62 #ifdef _DEBUG |
|
63 #ifdef LOG_TO_FILE |
|
64 RFileLogger logger; |
|
65 TInt ret = logger.Connect(); |
|
66 if (ret==KErrNone) |
|
67 { |
|
68 logger.SetDateAndTime( EFalse,EFalse ); |
|
69 logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend ); |
|
70 TBuf<KLogTimeFormatLength> timeStamp; |
|
71 TTime now; |
|
72 now.HomeTime(); |
|
73 TDateTime dateTime; |
|
74 dateTime = now.DateTime(); |
|
75 timeStamp.Format( KLogTimeFormat, |
|
76 dateTime.Hour(), dateTime.Minute(), |
|
77 dateTime.Second(), dateTime.MicroSecond() ); |
|
78 buf.Insert( 0, timeStamp ); |
|
79 |
|
80 logger.Write(buf); |
|
81 } |
|
82 |
|
83 logger.Close(); |
|
84 |
|
85 #else |
|
86 RDebug::Print( buf ); |
|
87 #endif // LOG_TO_FILE |
|
88 #endif // _DEBUG |
|
89 VA_END( args ); |
|
90 } |
|
91 |
|
92 #endif // ENABLE_LOGGING |
|
93 |
|
94 // End of file |