C12Adapter Opensource C++ Interface
|
Log file writer, one that writes information to a file. More...
Public Member Functions | |
MLogFileWriter () | |
Constructor that creates an uninitialized log file object. | |
MLogFileWriter (const MStdString &fileName, unsigned maxFileSizeKB=0) | |
Constructor that creates a writable log file with the given file name. More... | |
virtual | ~MLogFileWriter () |
Object destructor, close the log file. | |
unsigned | GetMaxFileSizeKB () const |
Get the maximum file size in kilobytes, or zero if the maximum file size is not set. More... | |
void | SetMaxFileSizeKB (unsigned size) |
Set the maximum file size in kilobytes, or zero if the maximum file size shall not be watched. More... | |
void | Open (const MStdString &fileName, unsigned maxFileSizeKB=0) |
Open the file for writing, or create a new one with the given name. More... | |
virtual void | Close () |
Close the file, if it was open. | |
void | Clear () |
Clear the contents of the file, if open, and start the log over from the beginning of the file. More... | |
void | WriteMessage (const char *data, size_t dataSize) |
Write the whole message to the log file. | |
void | WriteMessage (const MLogFile::PacketHeader &header, const char *data) |
Send the message with the prepared header. More... | |
void | WriteMessage (unsigned code, const char *message, unsigned length) |
Send the message with the specified code. More... | |
void | WriteMultipleMessages (const MByteString &messages) |
Send several messages formatted as a buffer containing packets. More... | |
![]() | |
virtual | ~MLogFile () |
Object destructor, close the log file. | |
bool | IsOpen () const |
Tells if the file is open. More... | |
const MStdString & | GetFileName () const |
Get the file name, as set for logging. More... | |
const MStdString & | GetOpenWarnings () const |
Get the warning message which might arise during opening a file and checking its contents. More... | |
void | SetListener (MMonitorFile *listener) |
Sets the listener object to start handling events. More... | |
bool | GetObfuscate () const |
void | SetObfuscate (bool yes) |
Additional Inherited Members | |
![]() | |
enum | { PAGE_HEADER_SIGNATURE = 0xA2EBBAED, PAGE_OBFUSCATED_HEADER_SIGNATURE = 0xA2EBBAEC, PAGE_TOTAL_SIZE = 0x1000, PAGE_HEADER_SIZE = 16, PAGE_FOOTER_SIZE = 4, PAGE_BODY_SIZE = PAGE_TOTAL_SIZE - PAGE_HEADER_SIZE - PAGE_FOOTER_SIZE, PACKET_HEADER_SIZE = 10, NUMBER_OF_PAGES_LIMIT = 0xFFFF } |
![]() | |
MLogFile () | |
Constructor that creates an uninitialized log file object. | |
Log file writer, one that writes information to a file.
It can be used separately from MMonitorFile to read and produce the log with the possible circular buffer behavior.
|
inlineexplicit |
Constructor that creates a writable log file with the given file name.
The value of maxFileSizeKB is taken into account to possibly limit the file size.
void MLogFileWriter::Clear | ( | ) |
Clear the contents of the file, if open, and start the log over from the beginning of the file.
It is not an error to clear the file which is not open.
|
inline |
Get the maximum file size in kilobytes, or zero if the maximum file size is not set.
Zero, there is no imposed restriction on the file size, is the default. Once the maximum size is achieved, the old data will start to disappear from the file as new data is added.
void MLogFileWriter::Open | ( | const MStdString & | fileName, |
unsigned | maxFileSizeKB = 0 |
||
) |
Open the file for writing, or create a new one with the given name.
The value of maxFileSizeKB is taken into account to possibly limit the file size.
void MLogFileWriter::SetMaxFileSizeKB | ( | unsigned | size | ) |
Set the maximum file size in kilobytes, or zero if the maximum file size shall not be watched.
Zero, there is no imposed restriction on the file size, is the default. Once the maximum size is achieved, the old data will start to disappear from the file as new data is added.
If a file exists prior the call, but its size is bigger than the imposing restriction, the file will be truncated (which can possibly take a significant amount of time).
void MLogFileWriter::WriteMessage | ( | const MLogFile::PacketHeader & | header, |
const char * | data | ||
) |
Send the message with the prepared header.
void MLogFileWriter::WriteMessage | ( | unsigned | code, |
const char * | message, | ||
unsigned | length | ||
) |
Send the message with the specified code.
void MLogFileWriter::WriteMultipleMessages | ( | const MByteString & | messages | ) |
Send several messages formatted as a buffer containing packets.