Author: Lee translated Article Source: newlc
Do I need to debug code or track the execution process on my mobile phone? Rfilelogger may help you. This class is very powerful and easy to use ._
First declare a file log connection and create a log file
Code:// Open the log file service connection
Rfilelogger ilog;
Ilog. Connect ();
Ilog. createlog (_ L ("myloggingdirectory"), _ L ("mylogfile"), efileloggingmodeoverwrite );
...
// Close the connection between the log file and the server
Ilog. closelog (); #, lfb9
Ilog. Close ();
The createlog function of Row 3 has three parameters: %
Log Path
Log File Name
Record mode (efileloggingmodeoverwrite | efileloggingmodeappend)
For example, the following code shows the full path of my log file (the file system on the mobile phone)
C:/logs/myloggingdirectory/mylogfile.
For me, I am used to putting opening code in the constructl () function of the class I want to trace, and then closing in the destructor. in real encoding, you 'd better check whether connect and createlog have returned kerrnone.
Once you have done this, you can input text and data to the log file. The basic commands are as follows:
Command Log File
Ilog. Write (_ L ("Hello World") fig 4:00:13 Hello World
Ilog. writeformat (_ L ("result = % d"), err) 11/07/2003 4:00:13 result = 0
Ilog. hexdump (aheader, aheader, myptr, 4) 11/07/2003 4:00:13 mybuf: 0000: 41 42 00 44 AB. d
If you do not want to record the date and time, you can use this statement to close them.
Code:Ilog. setdateandtime (tbool ausedate, tbool ausetime)
Do not forget to add flogger. lib to the MMP file and include the flogger. h header file. Now you can compile and execute your program.
No! The log file has not been created yet! Correct! This cannot be done in the code. We can only manually create a log file in the C:/logs/myloggingdirectory directory. Otherwise, no logs will be recorded. No need to recompile.
Note: If you do not know how to do this, you can use fexplorer to upload files to your mobile phone through a PC.
Http://www.symbianx.cn/viewthread.php? Tid = 27 & extra = Page % 3d1
Original address: http://newlc.com/article.php3? Id_article= 131