Write2Log()
Previous  Top  Next

:Write2Log() - Write Text to Log File.

Syntax

:Write2Log(<cLogText>,  
          [<nSkipLines>]) --> lLogStatus  

Parameters

<cLogText>  
<cLogText> specifies the Text string to be written (appended) to the Log File.  

<nSkipLines>  
<nSkipLines> optionally specifies the Number of empty lines that should be added to the Log File before the <cLogText> string is added. The default value is Zero ("0") lines.  

Returns

This method returns the current Logging Status: .T. (TRUE) if logging is enabled or .F. (FALSE) if logging is disabled.  

Description

If Logging is enabled, a Date/Time Stamp of the following format: "YYYY-MM-DD HH:MM:SS> " followed by the <cLogText> text string and a CRLF is added to the open Log File. If the log file entry should cover multiple lines, those lines can be added together by separating them with the "XBZ_NEXT_LOG_LINE" Define Constant, which consists of a CRLF followed by 21 space characters, which is the (current) length of the above mentioned Date/Time Stamp prefix.  
 
Also, before adding the <cLogText> text, a number of empty lines can be added to the Log File, to separate distinct groups of Log Entries, by specifying the number of empty lines with the <nSkipLines> parameter.  
 
This method can also be used to add additional Notes to the Log File, besides the internal default logging messages. If Logging is disabled, nothing can be added to the Log File, though!  

Example

Open an existing Zip File named "MyArchive.zip" in Test mode and if corrupted File Entries are found, start logging to a Log File named "MyArchive.log", add a note to the Log File, and then close the Zip File and the Log File:  

oZip := XbZLibZip():New("MyArchive.zip", XBZ_OPEN_TEST)  
if oZip:Status == XBZ_FILE_CORRUPT  
   oZip:StartLogging("MyArchive.log")  
   oZip:Write2Log("Found corrupted File Entries!")  
endif  
oZip:Close()