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