log.cpp

来自「短信拦截功能的 其他的自己看看吧 这里只有2nd的版本」· C++ 代码 · 共 115 行

CPP
115 行
字号
/*
============================================================================
 Name        : Log.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Log.cpp - source file
============================================================================
*/
#include "Log.h"
#include "flogger.h"

RLog* RLog::NewL() 
{    
	RLog* self = NewLC();
	CleanupStack::Pop(self);    
	return self;    
} 

RLog* RLog::NewLC()
{
	RLog* self = new (ELeave) RLog();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

RLog::RLog()
{    }

RLog::~RLog()
{    }

void RLog::ConstructL()
{    } 

void RLog::Log(TDes8 &aMsg)
{
	RFileLogger iLog;
	iLog.Connect();
	iLog.CreateLog(_L("Shell"),_L("log.txt"),EFileLoggingModeAppend);
	iLog.SetDateAndTime(EFalse,EFalse);
	iLog.Write(aMsg);
	// Close the log file and the connection to the server. 
	iLog.CloseLog();
	iLog.Close();
}

void RLog::Log(TDesC& aMsg)
{
	RFileLogger iLog;
	iLog.Connect();
	iLog.CreateLog(_L("Shell"),_L("log.txt"),EFileLoggingModeAppend);
	iLog.SetDateAndTime(EFalse,EFalse);
	iLog.Write(aMsg);
	// Close the log file and the connection to the server. 
	iLog.CloseLog();
	iLog.Close();
}

void RLog::Log(TPtrC aPtr)
{
	RFileLogger iLog;
	iLog.Connect();
	iLog.CreateLog(_L("Shell"),_L("log.txt"),EFileLoggingModeAppend);
	iLog.SetDateAndTime(EFalse,EFalse);
	TBuf<256> buf;
	buf.Copy(aPtr);
	iLog.Write(buf);
	// Close the log file and the connection to the server. 
	iLog.CloseLog();
	iLog.Close();
}

void RLog::Log(const TDes& aMsg)
{
	RFileLogger iLog;
	iLog.Connect();
	iLog.CreateLog(_L("Shell"),_L("log.txt"),EFileLoggingModeAppend);
	iLog.SetDateAndTime(EFalse,EFalse);
	iLog.Write(aMsg);
	// Close the log file and the connection to the server. 
	iLog.CloseLog();
	iLog.Close();
}
void RLog::Log(TInt aError)
{
	RFileLogger iLog;
	iLog.Connect();
	iLog.CreateLog(_L("Shell"),_L("log.txt"),EFileLoggingModeAppend);
	iLog.SetDateAndTime(EFalse,EFalse);
	TBuf<10> buf;
	buf.AppendNum(aError);
	iLog.Write(buf);
	// Close the log file and the connection to the server. 
	iLog.CloseLog();
	iLog.Close();
}
// void RLog::DeleteLog()
// {
// 	_LIT(KLogPath,"c:\\Logs\\Shell\\log.txt");
// 	RFs& fs = CCoeEnv::Static()->FsSession();
// 	//RFileReadStream readStream;
// 	TFileName fileName(KLogPath);
// 	/*
// 	if (BaflUtils::FileExists(fs,fileName))
// 		{
// 			User::LeaveIfError(fs.Delete(fileName));
// 		}*/
// 	
// 	RFile file;
// 	file.Replace(fs,fileName,EFileWrite);
// 	file.Close();
// }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?