Class com.innocuo.log.LaoLogger

Description

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).

Example

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.addBuffer(myBuffer);
	
		myLog.level=3;
		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

LaoLogger

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. *

Example

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

Parameters

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

level

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

Usage:

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.

Example:

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

defaultLogLevel

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.

uid

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

flushAfter

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

resetEventCount

public function resetEventCount():Void

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

addBuffer

public function addBuffer(qbuffer:LaoBuffer):Void

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

Parameters

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

removeBuffer

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

Parameters

qbufferis the buffer that will be removed from this logger

flushBuffers

public function flushBuffers()

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

clearBuffers

public function clearBuffers()

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

log

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.

Parameters

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.