|         |      1 /* | 
|         |      2 * Copyright (c) 2006 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: RingBCLog implementation | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18  | 
|         |     19  | 
|         |     20 // INCLUDE FILES | 
|         |     21  | 
|         |     22 #include <e32svr.h> | 
|         |     23 #include "RingBCLog.h" | 
|         |     24  | 
|         |     25  | 
|         |     26 #ifdef ENABLE_LOGGING | 
|         |     27 #include <flogger.h> | 
|         |     28  | 
|         |     29 /// Folder where the WMLBC log resides | 
|         |     30 _LIT( KLogFolder, "Smartmessaging" ); | 
|         |     31  | 
|         |     32 /// The name of the log file | 
|         |     33 _LIT( KLogFileName, "ringbc.txt" ); | 
|         |     34  | 
|         |     35 /// The format in which the time is formatted in log | 
|         |     36 _LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d "); | 
|         |     37  | 
|         |     38 /// The length of the string produced by KLogTimeFormat | 
|         |     39 const TInt KLogTimeFormatLength = 16; | 
|         |     40  | 
|         |     41 /// How many characters a log line can contain | 
|         |     42 const TInt KLogLineLength = 256; | 
|         |     43  | 
|         |     44 #endif // ENABLE_LOGGING | 
|         |     45  | 
|         |     46 // ================= MEMBER FUNCTIONS ======================= | 
|         |     47  | 
|         |     48 #ifdef ENABLE_LOGGING | 
|         |     49 // --------------------------------------------------------- | 
|         |     50 // Log() | 
|         |     51 // | 
|         |     52 // --------------------------------------------------------- | 
|         |     53 void Log::DoLog( TRefByValue<const TDesC> aText, ... ) | 
|         |     54     { | 
|         |     55     VA_LIST args; | 
|         |     56     VA_START( args, aText ); | 
|         |     57  | 
|         |     58     TBuf<256> buf; | 
|         |     59     buf.FormatList( aText, args ); | 
|         |     60  | 
|         |     61 #ifdef LOG_TO_FILE | 
|         |     62 	RFileLogger logger; | 
|         |     63 	TInt ret = logger.Connect(); | 
|         |     64 	if (ret==KErrNone) | 
|         |     65 		{ | 
|         |     66 		logger.SetDateAndTime( EFalse,EFalse ); | 
|         |     67 		logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend ); | 
|         |     68 		TBuf<KLogTimeFormatLength> timeStamp; | 
|         |     69 		TTime now; | 
|         |     70 		now.HomeTime(); | 
|         |     71 		TDateTime dateTime; | 
|         |     72 		dateTime = now.DateTime(); | 
|         |     73 		timeStamp.Format( KLogTimeFormat, | 
|         |     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 #else | 
|         |     84     RDebug::Print( buf ); | 
|         |     85 #endif // LOG_TO_FILE | 
|         |     86     VA_END( args ); | 
|         |     87     } | 
|         |     88  | 
|         |     89 #endif // ENABLE_LOGGING | 
|         |     90  | 
|         |     91 // End of file |