log_file
Description
We will always open and write(append) log files and then close so that it is crash proof debug log file store at your Origin home directory
Syntax
int log_file( LPCSTR lpcsz, BOOL bWrite )
Parameters
- lpcsz
- [input]
- if not NULL:
- if bWrite=true,lpcsz is the string to be written into debug log file
- if bWrite=false,create user define debug log file named lpcsz
- if NULL:
- if bWrite=true,reset to no-log-file state;
- if bWrite=false,return the status of log-file process
- bWrite
- [input] usage refer to lpcsz
Return
if lpcsz not NULL
if bWrite =true,if write the string into log file seccessfully,return the length of the string,else return -1
if bWrite =false,if create a new log file successfully,return 0,else return -1
if lpcsz = NULL
if bWrite = true,return 0
if bWrite =false,if log_file started return 1,else return -1
Examples
EX1
void log_file_ex1()
{
string strFile = "C:\\myLog.txt";
if ( log_file(strFile, false) == 0 ) //create successfully
{
log_file("some message...", true); //log some message
int nstate = log_file(NULL, false); //query state of log-file process
ASSERT(nstate == 1);
log_file(NULL, true); //reset to no log state
log_file("Can not log this message!", true); //try to log, this will fail since log-file process is reset
//after this code, you may find a file and check the content in it.
}
}
Remark
See Also
header to Include
origin.h
Reference
|