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