imstutils/xmppadapter/src/xmppadapterlogger.cpp
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     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:  XMPP Logger implementation
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include <e32svr.h>
       
    21 #include <e32std.h>
       
    22 #include <flogger.h>
       
    23 
       
    24 #include "xmppadapterlogger.h"
       
    25 
       
    26 
       
    27 /**
       
    28  * Handler used by logger to truncate the string
       
    29  * rather than panic in case of buffer overflow.
       
    30 */
       
    31 
       
    32 NONSHARABLE_CLASS ( TAdaptOverflowTruncate ) : public TDes16Overflow
       
    33 	{
       
    34 
       
    35 public:
       
    36 	void Overflow ( TDes16& /*aDes*/ ) {}
       
    37 	};
       
    38 
       
    39 // ============================ MEMBER FUNCTIONS ===============================
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // TLogger::WriteLog()
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void TLogger::WriteLog ( TRefByValue<const TDesC> aFmt, ... )
       
    46 	{
       
    47 #ifdef ENABLE_DEBUG_LOGS
       
    48 	( void ) aFmt;//Suppress unused formal parameter warning
       
    49 	TBuf< KTAdaptMaxLogLineLength > buffer;
       
    50 	buffer.Append ( _L ( "[" ) );           // CSI: 78 #
       
    51 	buffer.Append ( RThread().Name() );
       
    52 	buffer.Append ( _L ( "] " ) );          // CSI: 78 #
       
    53 	TAdaptOverflowTruncate overflow;
       
    54 	VA_LIST list;
       
    55 	VA_START ( list, aFmt );
       
    56 	buffer.AppendFormatList ( aFmt, list, &overflow );
       
    57 	RFileLogger logger;
       
    58 
       
    59 	if ( logger.Connect() == KErrNone )
       
    60 		{
       
    61 		logger.SetDateAndTime ( ETrue, ETrue );
       
    62 		logger.CreateLog ( KTAdaptDebugOutputDir, KTAdaptDebugOutputFileName,
       
    63 		                   EFileLoggingModeAppend );
       
    64 		logger.Write ( buffer );
       
    65 		logger.CloseLog();
       
    66 		logger.Close();
       
    67 		}
       
    68 
       
    69 #endif
       
    70 
       
    71 	}
       
    72 
       
    73 // End of File
       
    74 
       
    75