os/graphics/windowing/windowserver/debuglog/DEBLOGFL.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// code for the F32 derived class 
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "../SERVER/w32cmd.h"
sl@0
    19
#include "DEBLOGFL.H"
sl@0
    20
sl@0
    21
#define __FORCE_ASCII yes
sl@0
    22
sl@0
    23
#define DEFAULT_LOG_FILE_NAME _L("C:\\private\\10003b20\\WSERV.LOG")
sl@0
    24
sl@0
    25
/*#if defined(__WINS__)
sl@0
    26
#pragma data_seg(".E32_UID")
sl@0
    27
__WINS_UID(0, KWservLoggingDllUidValue, 0)
sl@0
    28
#pragma data_seg()
sl@0
    29
#endif*/
sl@0
    30
sl@0
    31
sl@0
    32
EXPORT_C CDebugLogBase *CreateDebugLog(TBool aIsFirst, TDesC &aParams)
sl@0
    33
	{
sl@0
    34
	CDebugLogFile *device=new(ELeave) CDebugLogFile();
sl@0
    35
	CDebugLog *log=NULL;
sl@0
    36
	TRAPD(err,log=new(ELeave) CDebugLog(device));
sl@0
    37
	if (err!=KErrNone)
sl@0
    38
		{
sl@0
    39
		delete device;
sl@0
    40
		User::Leave(err);
sl@0
    41
		}
sl@0
    42
	TRAP(err,log->ConstructL(aIsFirst, aParams));
sl@0
    43
	if (err!=KErrNone)
sl@0
    44
		{
sl@0
    45
		delete log;
sl@0
    46
		User::Leave(err);
sl@0
    47
		}
sl@0
    48
	return(log);
sl@0
    49
	}
sl@0
    50
sl@0
    51
CDebugLogFile::CDebugLogFile()
sl@0
    52
	{
sl@0
    53
	__DECLARE_NAME(_S("CDebugLogFile"));
sl@0
    54
	}
sl@0
    55
sl@0
    56
CDebugLogFile::~CDebugLogFile()
sl@0
    57
	{
sl@0
    58
	iFile.Close();
sl@0
    59
	iFs.Close();
sl@0
    60
	}
sl@0
    61
sl@0
    62
void CDebugLogFile::ConstructL(TBool aIsFirst, TDesC &aParams)
sl@0
    63
	{
sl@0
    64
	TPtrC defaultFileName(DEFAULT_LOG_FILE_NAME);
sl@0
    65
	TDesC *fileName=&aParams;
sl@0
    66
	if (aParams.Length()==0)
sl@0
    67
		fileName=&defaultFileName;
sl@0
    68
	User::LeaveIfError(iFs.Connect());
sl@0
    69
	//_LIT(KLog1,"Connected To File Server");
sl@0
    70
	//RDebug::Print(KLog1);
sl@0
    71
	iFs.MkDirAll(*fileName);
sl@0
    72
	if (aIsFirst)
sl@0
    73
		{
sl@0
    74
		User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters));
sl@0
    75
		//_LIT(KLog2,"Replaced File 1");
sl@0
    76
		//RDebug::Print(KLog2);
sl@0
    77
#if !defined(__FORCE_ASCII)
sl@0
    78
		TUint16 feffInt=0xFEFF;
sl@0
    79
		User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)&feffInt,2)));
sl@0
    80
#endif
sl@0
    81
		}
sl@0
    82
	else
sl@0
    83
		{
sl@0
    84
		TInt err=iFile.Open(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters);
sl@0
    85
		//_LIT(KLog3,"Done ReOpen");
sl@0
    86
		//RDebug::Print(KLog3);
sl@0
    87
		if (err==KErrNone)
sl@0
    88
			{
sl@0
    89
			TInt seekpos = 0;
sl@0
    90
			User::LeaveIfError(iFile.Seek(ESeekEnd,seekpos));
sl@0
    91
			}
sl@0
    92
		else
sl@0
    93
			User::LeaveIfError(iFile.Replace(iFs,*fileName,EFileStreamText|EFileWrite|EFileShareReadersOrWriters));
sl@0
    94
		}
sl@0
    95
	iEol16=TPtrC16((TUint16 *)_S("\r\n"));
sl@0
    96
	iEol.Set((TUint8 *)iEol16.Ptr(),iEol16.Size());
sl@0
    97
	iEol8=TPtrC8((TUint8 *)"\r\n");
sl@0
    98
	}
sl@0
    99
sl@0
   100
void CDebugLogFile::WriteToLogL(const TDesC &aDes, const TDesC &aDes2)
sl@0
   101
	{
sl@0
   102
#if defined(__FORCE_ASCII)
sl@0
   103
	TBuf8<128> des1;
sl@0
   104
	TBuf8<160> des2;
sl@0
   105
	des1.Copy(aDes);
sl@0
   106
	des2.Copy(aDes2);
sl@0
   107
	WriteToLog8L(des1,des2);
sl@0
   108
#else
sl@0
   109
	User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes.Ptr(),aDes.Size())));
sl@0
   110
	User::LeaveIfError(iFile.Write(iEol));
sl@0
   111
	User::LeaveIfError(iFile.Write(TPtrC8((TUint8 *)aDes2.Ptr(),aDes2.Size())));
sl@0
   112
	iFile.Flush();		//Ignore Error
sl@0
   113
#endif
sl@0
   114
	}
sl@0
   115
sl@0
   116
void CDebugLogFile::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2)
sl@0
   117
	{
sl@0
   118
	User::LeaveIfError(iFile.Write(aDes));
sl@0
   119
	User::LeaveIfError(iFile.Write(iEol8));
sl@0
   120
	User::LeaveIfError(iFile.Write(aDes2));
sl@0
   121
	iFile.Flush();		//Ignore Error
sl@0
   122
	}
sl@0
   123