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