Class com.innocuo.log.LaoLogger


This class lets you create Loggers, that can be used as replacement of the trace function. As it is not limited to output data to the output, you can really do a lot with this (for example: you could create a stats tracker app, with this class, a custom LaoBuffer and a php class).


This example shows how to create a logger and send messages to it
 		var myLog:LaoLogger=new LaoLogger("log1");
		var myBuffer:TraceBuffer=new TraceBuffer();
		myLog.log("this message will be published","EXAMPLE",2);
		myLog.log("this message won't, because its level is 5. Only messages with level 0 to 2 will","EXAMPLE",5)

See Also

Field Index

defaultLogLevel, flushAfter, level, uid

Method Index

new LaoLogger()
addBuffer(), clearBuffers(), flushBuffers(), log(), removeBuffer(), resetEventCount()

Constructor Detail


function LaoLogger(quid:String)

Tip: instead of using this class directly, it's better to use the LaoLoggerController class, with which you can create only one instance per specified name. The uid is not critical, is just an identifier, and it's possible that two different loggers have the same uid. *


var myLog:LaoLogger=new LaoLogger("log1");


quida string that specifies the name of the logger. If it is not set, the name of the logger will be the same as the one of the .swf file

Field Detail


public level:Number
Log level; it's a number. It is set to 0 by default.


when you send a log message, it'll check this level. If the debug level is greater than the message's level, the message gets published.


if level is 2, only messages with level 0,1 and too will be published.


public defaultLogLevel:Number
Default Log level for messages; if the received log message doesn't have a log level it'll use this number. It is set to 0 by default.


public uid:String [Read Only]
logger name, which is set when you instantiate the Class


public flushAfter:Number
Default is 0. If flushAfter is different than 0, flushBuffers method is called after the number of messages received is the same as this number Messages are only counted if they pass the log level check.

Method Detail


public function resetEventCount():Void

Resets the internal counter of successfully received messages it is only useful when you're using flushAfter.


public function addBuffer(qbuffer:LaoBuffer):Void

Laologger can work with more than one LaoBuffers. You add them with this method.


qbufferis the buffer that will be used. Of course, you have to create it first The buffer is registered for three events: log (to send log messages to them), flush and clear


public function removeBuffer(qbuffer:LaoBuffer):Void

Removes a buffer from the logger. You have to pass the entire object, not just the name. This method just unregistrers the buffer, but doesn't delete it


qbufferis the buffer that will be removed from this logger


public function flushBuffers()

sends a flush message to the registrered LaoBuffers. The buffer is the one that decides what to do.


public function clearBuffers()

sends a clear message to the registrered LaoBuffer. The buffer is the one that decides what to do.


public function log(qargument, qtype:String, qlevel:Number)

checks if the message's log level is less than the one set for the logger if so, the message is sent to all registrered LaoBuffers. This is one of three type of messages the buffers can receive. The others are flush and clear, though they are internal, you can only call them using clearBuffers and flushBuffers.


qargumentthe message (usually just a string) that you want to send to the buffer.
qtypea reference number for the message.
qlevelis the message's log level. If it is null, the defaultLogLevel will be used.