FilePrinter
Class Description
Provides a file logger with a fixed buffer size for use by Log
.
Log messages are written to file via system.platform.File
, which requires
a full file write each time (there is no write-append method for File
). To
prevent memory overflow, the printer stores a limited number of messages in a buffer,
replacing oldest ones with newest ones when the limit is reached (first in, last out).
Messages can be appended to or replaced. The buffer is written to disk after each print operation.
See Also
- system.platform.File
Listing
Fields
data():Vector.<String> | The message buffer. |
Properties
messageLimit():Number | Specify the maximum number of messages to buffer and write. |
logfile():String | read only Retrieve the current path to the logfile. |
Methods
print(message:String):void | Record a log message. |
append(message:String):void | Add on to the latest existing message. |
replace(message:String):void | Replace the latest existing message. |
setLogfile(filepath:String):Boolean | Specify the path of the logfile to use. |
save():Boolean | Write the current message queue to disk. |
Details
Fields
data
protected data():Vector.<String>
The message buffer.
Number of messages stored in the buffer is capped by messageLimit
.
See Also
Properties
messageLimit
public messageLimit():Number
Specify the maximum number of messages to buffer and write.
logfileread only
public logfile():String
Retrieve the current path to the logfile.
Methods
print()
public function print(message:String):void
Record a log message.
Message formatting occurs prior to this method being called.
message:String | The formatted message to be handled by a log receiver |
append()
public function append(message:String):void
Add on to the latest existing message.
If called before any message has been logged, append()
will function as print()
.
message:String | String to be appended to end of latest existing message |
replace()
public function replace(message:String):void
Replace the latest existing message.
If called before any message has been logged, replace()
will function as print()
.
message:String | String to overwrite latest existing message |
setLogfile()
public function setLogfile(filepath:String):Boolean
Specify the path of the logfile to use.
The logfile will be created if it doesn’t already exist.
filepath:String | Path to logfile (full or relative to default writeable directory) |
returns Boolean |
|
save()
protected function save():Boolean
Write the current message queue to disk.
Called after each print()
, append()
, or replace()
operation.
returns Boolean |
|