⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.cpp

📁 短信拦截功能的 其他的自己看看吧 这里只有2nd的版本
💻 CPP
字号:
/*
============================================================================
 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -