![]() |
Barst
2.0
A server that controls lab hardware.
|
#include <Log buffer.h>
Public Member Functions | |
int | Add (const TCHAR *szItem) |
void | MoveLog (char szDest[][128], int nToWrite, int *pnWrote) |
int | GetSize () |
void | ClearLog () |
Defines a log format. Currently not implemented. A ring buffer type class that holds a list of text items. You can store LOG_LENGTH items in the array and the length of each item is of maximum LOG_TEXT_LENGTH.
Every time an item is added a line number and time of add is appended to it at the start. Line number is a 64 bit int so it will overflow. These line numbers start from 1 as zero would indicate there is no error to return in a line.
Also, if you don't retrieve the log periodically since old log items will simply be overwritten. Class is completly thread safe.
Definition at line 22 of file Log buffer.h.
|
inline |
Function to add item to the log. The function appends a line number and time added at the start of the item. return: The line number appended to the item added.
Definition at line 39 of file Log buffer.h.
|
inline |
Empties and resets the log.
Definition at line 50 of file Log buffer.h.
|
inline |
The number of items/lines currently in the log.
Definition at line 48 of file Log buffer.h.
|
inline |
Copies and deletes the min of nToWrite and # of log items available from the log into szDest. It's assumed that the length of szDest is at least nToWrite*LOG_TEXT_LENGTH. szDest: Where the log will be copied into. Each LOG_TEXT_LENGTH section of the array holds a null terminated string. If the log item is smaller than LOG_TEXT_LENGTH, then the rest is filled up with zeros. nToWrite: Number of items/lines to move. nWrote: Number of items actually written, it's the minimum of nToWrite and the number of items currently in the log.
Definition at line 46 of file Log buffer.h.