diff -r e8c1ea2c6496 -r 8758140453c0 graphics/wserv/AnimPlugin/src/T_log.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graphics/wserv/AnimPlugin/src/T_log.cpp Thu Jan 21 12:53:44 2010 +0000 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "T_log.h" + +#define DES_AS_8_BIT(str) (TPtrC8((TText8*)((str).Ptr()), (str).Size())) +_LIT8(KLimit,"\r\n"); +_LIT8(KTimeFormat, "%2d:%2d:%3d "); + +CLog::CLog() + { + + } + +CLog::~CLog() + { + iFile.Close(); + + iBuf.Close(); + } + +CLog* CLog::NewLC(RFs &aFs, const TDesC &aFileName) + { + CLog* self = new (ELeave)CLog(); + CleanupStack::PushL(self); + self->ConstructL(aFs,aFileName); + return self; + } + +CLog* CLog::NewL(RFs &aFs, const TDesC &aFileName) + { + CLog* self=CLog::NewLC(aFs, aFileName); + CleanupStack::Pop(); // self; + return self; + } + +void CLog::ConstructL(RFs &aFs, const TDesC &aFileName) + { + User::LeaveIfError(iFile.Replace(aFs,aFileName,EFileWrite|EFileShareAny)); + + iText.Set(iFile); + iBuf.Create(1024); + + } +//write log +//input: aInfo, text msg; +//return: KErrNone, ok; other, fail; +TInt CLog::WriteLog(const TDesC& aInfo) + { + TTime currentTime; + currentTime.HomeTime(); + TDateTime time=currentTime.DateTime(); + + iBuf.Format(KTimeFormat,time.Minute(),time.Second(),time.MicroSecond()); + iBuf.Append(aInfo); + + iFile.Write(iBuf); + iFile.Write(KLimit); + + return 0; + } + +//write log +//input: aInfo, text msg; +//return: KErrNone, ok; other, fail; +TInt CLog::WriteLog(const TDesC8& aInfo) + { + TTime currentTime; + currentTime.HomeTime(); + TDateTime time=currentTime.DateTime(); + + iBuf.Format(KTimeFormat,time.Minute(),time.Second(),time.MicroSecond()); + iBuf.Append(aInfo); + + iFile.Write(iBuf); + iFile.Write(KLimit); + + return 0; + }