cbsref/telephonyrefplugins/atltsy/atcommand/generic/src/mslogger.cpp
branchRCL_3
changeset 65 630d2f34d719
equal deleted inserted replaced
61:17af172ffa5f 65:630d2f34d719
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // TSYLogger
       
    15 
       
    16 // system inlcude
       
    17 #include <flogger.h>		// for FLogger
       
    18 
       
    19 // user include
       
    20 #include "mslogger.h"		// Header file for this source file
       
    21 
       
    22 // const defination
       
    23 _LIT(KLogFolder,"etel");
       
    24 _LIT(KLogFileName,"PhoneTsy.txt");
       
    25 _LIT8(KTimeFormat,"%02d:%02d:%02d.%03d ");
       
    26 
       
    27 const TInt KTSYLogBufferSize=400;
       
    28 
       
    29 void TSYLogger::Write(const TDesC8& aText)
       
    30 	{
       
    31 	//
       
    32 	// Assemble time stamp and callers text into one string
       
    33 	TBuf8<KTSYLogBufferSize> buf;
       
    34 	TTime now;
       
    35 	now.UniversalTime();
       
    36 	TDateTime t(now.DateTime());
       
    37 	buf.Format(KTimeFormat,t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
       
    38 	buf.Append(aText);
       
    39 
       
    40 	//
       
    41 	// Open log, write text to log and close log
       
    42 	RFileLogger log;
       
    43 	if(KErrNone==log.Connect())
       
    44 		{
       
    45 		log.CreateLog(KLogFolder,KLogFileName,EFileLoggingModeAppend);
       
    46 		log.SetDateAndTime(EFalse,EFalse);
       
    47 		log.Write(buf);
       
    48 		log.CloseLog();
       
    49 		log.Close();
       
    50 		}
       
    51 	}
       
    52 
       
    53 
       
    54 void TSYLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...)
       
    55 	{
       
    56 	VA_LIST list;
       
    57 	VA_START(list,aFmt);
       
    58 
       
    59 	//
       
    60 	// Assemble time stamp and callers text into one string
       
    61 	TBuf8<KTSYLogBufferSize> buf;
       
    62 	TTime now;
       
    63 	now.UniversalTime();
       
    64 	TDateTime t(now.DateTime());
       
    65 	buf.Format(KTimeFormat,t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
       
    66 	buf.AppendFormatList(aFmt,list);
       
    67 
       
    68 	//
       
    69 	// Open log, write text to log and close log
       
    70 	RFileLogger log;
       
    71 	if(KErrNone==log.Connect())
       
    72 		{
       
    73 		log.CreateLog(KLogFolder,KLogFileName,EFileLoggingModeAppend);
       
    74 		log.SetDateAndTime(EFalse,EFalse);
       
    75 		log.Write(buf);
       
    76 		log.CloseLog();
       
    77 		log.Close();
       
    78 		}
       
    79 	}
       
    80