1 /* |
|
2 * Copyright (c) 2008 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 for locbtnotifer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "locbtnotifierdebug.h" |
|
22 #include <flogger.h> |
|
23 #include <e32svr.h> |
|
24 // CONSTANTS |
|
25 |
|
26 /// Folder where the log resides |
|
27 _LIT( KLogFolder, "LocBtNotifier" ); |
|
28 |
|
29 /// The name of the log file |
|
30 _LIT( KLogFileName, "LocBtNotifier" ); |
|
31 |
|
32 /// The format in which the time is formatted in log |
|
33 _LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d "); |
|
34 |
|
35 /// The length of the string produced by KLocLogTimeFormat |
|
36 const TInt KLogTimeFormatLength = 16; |
|
37 |
|
38 /// How many characters a log line can contain |
|
39 const TInt KLogLineLength = 256; |
|
40 |
|
41 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
42 |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // DebugLocBtNotifier |
|
46 // Generates a log file if c:\logs\locbtnotifier\ folder exists |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void DebugLocBtNotifier( TRefByValue<const TDesC> aText, ... ) |
|
50 { |
|
51 // coverity[var_decl : FALSE] |
|
52 VA_LIST args; |
|
53 VA_START( args, aText ); |
|
54 |
|
55 TBuf<KLogLineLength> buf; |
|
56 // coverity[uninit_use_in_call : FALSE] |
|
57 buf.FormatList( aText, args ); |
|
58 |
|
59 #ifdef _DEBUG |
|
60 RDebug::Print(buf); |
|
61 #endif |
|
62 |
|
63 RFileLogger logger; |
|
64 |
|
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 VA_END( args ); |
|
86 } |
|
87 |
|
88 // End of File |
|