1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/debuglog/DEBLOGFL.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,123 @@
1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// code for the F32 derived class
1.18 +//
1.19 +//
1.20 +
1.21 +#include "../SERVER/w32cmd.h"
1.22 +#include "DEBLOGFL.H"
1.23 +
1.24 +#define __FORCE_ASCII yes
1.25 +
1.26 +#define DEFAULT_LOG_FILE_NAME _L("C:\\private\\10003b20\\WSERV.LOG")
1.27 +
1.28 +/*#if defined(__WINS__)
1.29 +#pragma data_seg(".E32_UID")
1.30 +__WINS_UID(0, KWservLoggingDllUidValue, 0)
1.31 +#pragma data_seg()
1.32 +#endif*/
1.33 +
1.34 +
1.35 +EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
1.36 + {
1.37 + CDebugLogFile *device=new(ELeave) CDebugLogFile();
1.38 + CDebugLog *log=NULL;
1.39 + TRAPD(err,log=new(ELeave) CDebugLog(device));
1.40 + if (err!=KErrNone)
1.41 + {
1.42 + delete device;
1.43 + User::Leave(err);
1.44 + }
1.45 + TRAP(err,log->ConstructL(aIsFirst, aParams));
1.46 + if (err!=KErrNone)
1.47 + {
1.48 + delete log;
1.49 + User::Leave(err);
1.50 + }
1.51 + return(log);
1.52 + }
1.53 +
1.54 +CDebugLogFile::CDebugLogFile()
1.55 + {
1.56 + __DECLARE_NAME(_S("CDebugLogFile"));
1.57 + }
1.58 +
1.59 +CDebugLogFile::~CDebugLogFile()
1.60 + {
1.61 + iFile.Close();
1.62 + iFs.Close();
1.63 + }
1.64 +
1.65 +void CDebugLogFile::ConstructL(TBool aIsFirst, TDesC &aParams)
1.66 + {
1.67 + TPtrC defaultFileName(DEFAULT_LOG_FILE_NAME);
1.68 + TDesC *fileName=&aParams;
1.69 + if (aParams.Length()==0)
1.70 + fileName=&defaultFileName;
1.71 + User::LeaveIfError(iFs.Connect());
1.72 + //_LIT(KLog1,"Connected To File Server");
1.73 + //RDebug::Print(KLog1);
1.74 + iFs.MkDirAll(*fileName);
1.75 + if (aIsFirst)
1.76 + {
1.77 + User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters));
1.78 + //_LIT(KLog2,"Replaced File 1");
1.79 + //RDebug::Print(KLog2);
1.80 +#if !defined(__FORCE_ASCII)
1.81 + TUint16 feffInt=0xFEFF;
1.82 + User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)&feffInt,2)));
1.83 +#endif
1.84 + }
1.85 + else
1.86 + {
1.87 + TInt err=iFile.Open(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters);
1.88 + //_LIT(KLog3,"Done ReOpen");
1.89 + //RDebug::Print(KLog3);
1.90 + if (err==KErrNone)
1.91 + {
1.92 + TInt seekpos = 0;
1.93 + User::LeaveIfError(iFile.Seek(ESeekEnd,seekpos));
1.94 + }
1.95 + else
1.96 + User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters));
1.97 + }
1.98 + iEol16=TPtrC16((TUint16 *)_S("\r\n"));
1.99 + iEol.Set((TUint8 *)iEol16.Ptr(),iEol16.Size());
1.100 + iEol8=TPtrC8((TUint8 *)"\r\n");
1.101 + }
1.102 +
1.103 +void CDebugLogFile::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
1.104 + {
1.105 +#if defined(__FORCE_ASCII)
1.106 + TBuf8<128> des1;
1.107 + TBuf8<160> des2;
1.108 + des1.Copy(aDes);
1.109 + des2.Copy(aDes2);
1.110 + WriteToLog8L(des1,des2);
1.111 +#else
1.112 + User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes.Ptr(),aDes.Size())));
1.113 + User::LeaveIfError(iFile.Write(iEol));
1.114 + User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size())));
1.115 + iFile.Flush(); //Ignore Error
1.116 +#endif
1.117 + }
1.118 +
1.119 +void CDebugLogFile::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
1.120 + {
1.121 + User::LeaveIfError(iFile.Write(aDes));
1.122 + User::LeaveIfError(iFile.Write(iEol8));
1.123 + User::LeaveIfError(iFile.Write(aDes2));
1.124 + iFile.Flush(); //Ignore Error
1.125 + }
1.126 +