sl@0: // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // code for the F32 derived class sl@0: // sl@0: // sl@0: sl@0: #include "../SERVER/w32cmd.h" sl@0: #include "DEBLOGFL.H" sl@0: sl@0: #define __FORCE_ASCII yes sl@0: sl@0: #define DEFAULT_LOG_FILE_NAME _L("C:\\private\\10003b20\\WSERV.LOG") sl@0: sl@0: /*#if defined(__WINS__) sl@0: #pragma data_seg(".E32_UID") sl@0: __WINS_UID(0, KWservLoggingDllUidValue, 0) sl@0: #pragma data_seg() sl@0: #endif*/ sl@0: sl@0: sl@0: EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams) sl@0: { sl@0: CDebugLogFile *device=new(ELeave) CDebugLogFile(); sl@0: CDebugLog *log=NULL; sl@0: TRAPD(err,log=new(ELeave) CDebugLog(device)); sl@0: if (err!=KErrNone) sl@0: { sl@0: delete device; sl@0: User::Leave(err); sl@0: } sl@0: TRAP(err,log->ConstructL(aIsFirst, aParams)); sl@0: if (err!=KErrNone) sl@0: { sl@0: delete log; sl@0: User::Leave(err); sl@0: } sl@0: return(log); sl@0: } sl@0: sl@0: CDebugLogFile::CDebugLogFile() sl@0: { sl@0: __DECLARE_NAME(_S("CDebugLogFile")); sl@0: } sl@0: sl@0: CDebugLogFile::~CDebugLogFile() sl@0: { sl@0: iFile.Close(); sl@0: iFs.Close(); sl@0: } sl@0: sl@0: void CDebugLogFile::ConstructL(TBool aIsFirst, TDesC &aParams) sl@0: { sl@0: TPtrC defaultFileName(DEFAULT_LOG_FILE_NAME); sl@0: TDesC *fileName=&aParams; sl@0: if (aParams.Length()==0) sl@0: fileName=&defaultFileName; sl@0: User::LeaveIfError(iFs.Connect()); sl@0: //_LIT(KLog1,"Connected To File Server"); sl@0: //RDebug::Print(KLog1); sl@0: iFs.MkDirAll(*fileName); sl@0: if (aIsFirst) sl@0: { sl@0: User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters)); sl@0: //_LIT(KLog2,"Replaced File 1"); sl@0: //RDebug::Print(KLog2); sl@0: #if !defined(__FORCE_ASCII) sl@0: TUint16 feffInt=0xFEFF; sl@0: User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)&feffInt,2))); sl@0: #endif sl@0: } sl@0: else sl@0: { sl@0: TInt err=iFile.Open(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters); sl@0: //_LIT(KLog3,"Done ReOpen"); sl@0: //RDebug::Print(KLog3); sl@0: if (err==KErrNone) sl@0: { sl@0: TInt seekpos = 0; sl@0: User::LeaveIfError(iFile.Seek(ESeekEnd,seekpos)); sl@0: } sl@0: else sl@0: User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters)); sl@0: } sl@0: iEol16=TPtrC16((TUint16 *)_S("\r\n")); sl@0: iEol.Set((TUint8 *)iEol16.Ptr(),iEol16.Size()); sl@0: iEol8=TPtrC8((TUint8 *)"\r\n"); sl@0: } sl@0: sl@0: void CDebugLogFile::WriteToLogL(const TDesC &aDes, const TDesC &aDes2) sl@0: { sl@0: #if defined(__FORCE_ASCII) sl@0: TBuf8<128> des1; sl@0: TBuf8<160> des2; sl@0: des1.Copy(aDes); sl@0: des2.Copy(aDes2); sl@0: WriteToLog8L(des1,des2); sl@0: #else sl@0: User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes.Ptr(),aDes.Size()))); sl@0: User::LeaveIfError(iFile.Write(iEol)); sl@0: User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size()))); sl@0: iFile.Flush(); //Ignore Error sl@0: #endif sl@0: } sl@0: sl@0: void CDebugLogFile::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2) sl@0: { sl@0: User::LeaveIfError(iFile.Write(aDes)); sl@0: User::LeaveIfError(iFile.Write(iEol8)); sl@0: User::LeaveIfError(iFile.Write(aDes2)); sl@0: iFile.Flush(); //Ignore Error sl@0: } sl@0: