messagingappbase/smartmessaging/vrec/src/VRecLog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 static utility functions for CWmlBMSubItem.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "VRecLog.h"
       
    24 
       
    25 #ifdef ENABLE_LOGGING
       
    26 #include <flogger.h>
       
    27 #include <E32SVR.H>
       
    28 
       
    29 /// Folder where the VREC log resides
       
    30 _LIT( KLogFolder, "vrec" );
       
    31 
       
    32 /// The name of the log file
       
    33 _LIT( KLogFileName, "vrec.log" );
       
    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 // LogIt() 
       
    51 //
       
    52 // ---------------------------------------------------------
       
    53 void Log::LogIt( 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 
       
    87     VA_END( args );
       
    88     }
       
    89 
       
    90 #endif // ENABLE_LOGGING
       
    91 
       
    92 // End of file