messagingappbase/smartmessaging/wmlbc/src/WmlLog.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 <e32svr.h>
       
    24 #include "WmlLog.h"
       
    25 
       
    26 
       
    27 #ifdef WMLBC_ENABLE_LOGGING
       
    28 #include <flogger.h>
       
    29 
       
    30 #ifdef _DEBUG
       
    31 #ifdef WMLBC_LOG_TO_FILE
       
    32 /// Folder where the WMLBC log resides
       
    33 _LIT( KLogFolder, "wmlbc" );
       
    34 
       
    35 /// The name of the log file
       
    36 _LIT( KLogFileName, "wmlbc" );
       
    37 
       
    38 /// The format in which the time is formatted in log
       
    39 _LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d ");
       
    40 
       
    41 /// The length of the string produced by KLogTimeFormat
       
    42 const TInt KLogTimeFormatLength = 16;
       
    43 
       
    44 /// How many characters a log line can contain
       
    45 const TInt KLogLineLength = 256;
       
    46 #endif
       
    47 #endif
       
    48 
       
    49 #endif // WMLBC_ENABLE_LOGGING       
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =======================
       
    52 
       
    53 #ifdef WMLBC_ENABLE_LOGGING
       
    54 // ---------------------------------------------------------
       
    55 // Log() 
       
    56 //
       
    57 // ---------------------------------------------------------
       
    58 void WmlLog::Log( TRefByValue<const TDesC> aText, ... )
       
    59     {
       
    60     VA_LIST args;
       
    61     VA_START( args, aText );
       
    62 
       
    63     TBuf<256> buf;
       
    64     buf.FormatList( aText, args );
       
    65 
       
    66 #ifdef _DEBUG
       
    67 #ifdef WMLBC_LOG_TO_FILE
       
    68 	RFileLogger logger;
       
    69 	TInt ret = logger.Connect();
       
    70 	if (ret==KErrNone)
       
    71 		{
       
    72 		logger.SetDateAndTime( EFalse,EFalse );
       
    73 		logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );		
       
    74 		TBuf<KLogTimeFormatLength> timeStamp;
       
    75 		TTime now;
       
    76 		now.HomeTime();
       
    77 		TDateTime dateTime;
       
    78 		dateTime = now.DateTime();
       
    79 		timeStamp.Format( KLogTimeFormat, 
       
    80             dateTime.Hour(), dateTime.Minute(),
       
    81             dateTime.Second(), dateTime.MicroSecond() );
       
    82 		buf.Insert( 0, timeStamp );
       
    83 
       
    84 		logger.Write(buf);
       
    85 		}
       
    86 
       
    87 	logger.Close();
       
    88 
       
    89 #else
       
    90     RDebug::Print( buf );
       
    91 #endif // WMLBC_LOG_TO_FILE
       
    92 #endif // _DEBUG
       
    93     VA_END( args );
       
    94     }
       
    95 
       
    96 #endif // WMLBC_ENABLE_LOGGING
       
    97 
       
    98 // End of file