📄 log.cpp
字号:
#include <e32base.h>
002 #include <flogger.h>
003 #include <e32svr.h>
004
005 void LogL(const TDesC& msg)
006 {
007 RFileLogger iLog;
008 User::LeaveIfError(iLog.Connect());
009 CleanupClosePushL(iLog);
010 iLog.CreateLog(_L("Context"),_L("Notify"),EFileLoggingModeAppend);
011 RDebug::Print(msg.Left(128));
012
013 iLog.CloseLog();
014 CleanupStack::PopAndDestroy();
015 }
016
017 void Log(const TDesC& msg)
018 {
019 TRAPD(err, LogL(msg));
020 // ignore error, not much else we can do
021 // and not critical
022 }
023 void LogL(const TDesC8& msg)
024 {
025 RFileLogger iLog;
026 User::LeaveIfError(iLog.Connect());
027 CleanupClosePushL(iLog);
028 iLog.CreateLog(_L("Context"),_L("Notify"),EFileLoggingModeAppend);
029 iLog.Write(msg);
030 //RDebug::Print(msg);
031
032 // Close the log file and the connection to the server.
033 iLog.CloseLog();
034 CleanupStack::PopAndDestroy();
035 }
036
037 void Log(const TDesC8& msg)
038 {
039 TRAPD(err, LogL(msg));
040 // ignore error, not much else we can do
041 // and not critical
042 }
043
044 void LogL(const TDesC& msg, TInt i)
045 {
046 RFileLogger iLog;
047 User::LeaveIfError(iLog.Connect());
048 CleanupClosePushL(iLog);
049 iLog.CreateLog(_L("Context"),_L("Notify"),EFileLoggingModeAppend);
050 iLog.Write(msg);
051 RDebug::Print(msg.Left(128));
052 TBuf<10> iBuf;
053 iBuf.Format(_L("%d"),i);
054 iLog.Write(iBuf);
055 RDebug::Print(iBuf);
056 // Close the log file and the connection to the server.
057 iLog.CloseLog();
058 CleanupStack::PopAndDestroy();
059 }
060
061 void Log(const TDesC& msg, TInt /*i*/)
062 {
063 TRAPD(err, LogL(msg));
064 // ignore error, not much else we can do
065 // and not critical
066 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -