|
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: |
|
15 * Class offers logging functions |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <e32svr.h> |
|
24 #include "ICalUILog.h" |
|
25 |
|
26 #ifdef ICALUI_ENABLE_LOGGING |
|
27 #include <flogger.h> |
|
28 |
|
29 /// Folder where the log resides |
|
30 _LIT( KLogFolder, "icalui" ); |
|
31 |
|
32 /// The name of the log file |
|
33 _LIT( KLogFileName, "icalui.txt" ); |
|
34 |
|
35 /// How many characters a log line can contain |
|
36 const TInt KLogLineLength = 256; |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // Log() |
|
40 // |
|
41 // --------------------------------------------------------- |
|
42 void ICalUILog::Log( TRefByValue<const TDesC> aText, ... ) |
|
43 { |
|
44 VA_LIST args; |
|
45 VA_START( args, aText ); |
|
46 |
|
47 TBuf<KLogLineLength> buf; |
|
48 buf.FormatList( aText, args ); |
|
49 |
|
50 #ifdef ICALUI_LOG_TO_FILE |
|
51 RFileLogger logger; |
|
52 TInt ret = logger.Connect(); |
|
53 if (ret==KErrNone) |
|
54 { |
|
55 logger.SetDateAndTime( EFalse,EFalse ); |
|
56 logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend ); |
|
57 TBuf<KLogTimeFormatLength> timeStamp; |
|
58 TTime now; |
|
59 now.HomeTime(); |
|
60 TDateTime dateTime; |
|
61 dateTime = now.DateTime(); |
|
62 timeStamp.Format( KLogTimeFormat, |
|
63 dateTime.Hour(), dateTime.Minute(), |
|
64 dateTime.Second(), dateTime.MicroSecond() ); |
|
65 buf.Insert( 0, timeStamp ); |
|
66 |
|
67 logger.Write(buf); |
|
68 } |
|
69 |
|
70 logger.Close(); |
|
71 |
|
72 #else |
|
73 RDebug::Print( buf ); |
|
74 #endif // ICALUI_LOG_TO_FILE |
|
75 VA_END( args ); |
|
76 } |
|
77 |
|
78 #endif // ICALUI_ENABLE_LOGGING |
|
79 |
|
80 // End of file |