TextLogger Prototype
Serializer for lists of data that can be printed line-by-line. If you pass an autoLimit, it will automatically call limit() once the number of appended items exceeds the limit (so the number of items will never exceed limit*2).
Syntax
var object = new TextLogger(path, autoLimit);
Arguments
| Argument | Summary |
|---|---|
| path | |
| autoLimit |
Remarks
Members
| Member | Summary |
|---|---|
| append | Append data (an array or single item) to the file |
| limit | Limit the data already in the file to the data provided, or the count given. |
| read | Reads out the data currently in the file, and returns an array. |
See Also
Source Code
function TextLogger(path, autoLimit)
{
// Check if we can open the path. This will throw if it doesn't work
var f = fopen(path, ">>");
f.close();
this.path = path;
this.appended = 0;
if (typeof autoLimit == "number")
this.autoLimit = autoLimit;
else
this.autoLimit = -1;
// Limit the amount of data in the file when constructing, when asked to.
if (this.autoLimit != -1)
this.limit();
}