|
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: LandmarksUi Content File - Contains debugging functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include "Debug.h" |
|
27 #include <flogger.h> |
|
28 #include <e32svr.h> |
|
29 |
|
30 #ifdef __LMK_DEBUG_FLAG |
|
31 |
|
32 // CONSTANTS |
|
33 #ifdef _DEBUG |
|
34 /// Folder where the log resides |
|
35 _LIT( KLogFolder, "Lmk" ); |
|
36 |
|
37 /// The name of the log file |
|
38 _LIT( KLogFileName, "Lmk" ); |
|
39 |
|
40 /// The format in which the time is formatted in log |
|
41 _LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d "); |
|
42 |
|
43 /// The length of the string produced by KLocLogTimeFormat |
|
44 const TInt KLogTimeFormatLength = 16; |
|
45 |
|
46 /// How many characters a log line can contain |
|
47 const TInt KLogLineLength = 256; |
|
48 #endif |
|
49 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // Debug |
|
54 // Generates a log file if c:\logs\LMK\ folder exists |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void Debug( TRefByValue<const TDesC> aText, ... ) |
|
58 { |
|
59 #ifdef _DEBUG |
|
60 RDebug::Print(aText); |
|
61 |
|
62 VA_LIST args; |
|
63 VA_START( args, aText ); |
|
64 |
|
65 TBuf<KLogLineLength> buf; |
|
66 buf.FormatList( aText, args ); |
|
67 |
|
68 RFileLogger logger; |
|
69 TInt ret=logger.Connect(); |
|
70 if (ret==KErrNone) |
|
71 { |
|
72 logger.SetDateAndTime( EFalse,EFalse ); |
|
73 logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend ); |
|
74 TBuf<KLogTimeFormatLength> timeStamp; |
|
75 TTime now; |
|
76 now.HomeTime(); |
|
77 TDateTime dateTime; |
|
78 dateTime = now.DateTime(); |
|
79 timeStamp.Format( KLogTimeFormat, |
|
80 dateTime.Hour(), dateTime.Minute(), |
|
81 dateTime.Second(), dateTime.MicroSecond() ); |
|
82 buf.Insert( 0, timeStamp ); |
|
83 |
|
84 logger.Write(buf); |
|
85 } |
|
86 |
|
87 logger.Close(); |
|
88 |
|
89 VA_END( args ); |
|
90 #endif |
|
91 } |
|
92 |
|
93 #endif // __LMK_DEBUG_FLAG |
|
94 |
|
95 // End of File |